mad_compile_SUITE.erl 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. -module(mad_compile_SUITE).
  2. -export([all/0]).
  3. -export([erl_files/1]).
  4. -export([app_src_files/1]).
  5. -export([is_app_src/1]).
  6. -export([app_src_to_app/1]).
  7. -export([erl_to_beam/1]).
  8. -export([deps/1]).
  9. -export([app/1]).
  10. -export([is_compiled/1]).
  11. -import(helper, [get_value/2]).
  12. all() ->
  13. [
  14. erl_files, app_src_files, is_app_src, app_src_to_app, erl_to_beam, deps,
  15. app, is_compiled
  16. ].
  17. erl_files(Config) ->
  18. DataDir = get_value(data_dir, Config),
  19. SrcDir = filename:join([DataDir, "deps", "one", "src"]),
  20. ErlFile = filename:join(SrcDir, "one.erl"),
  21. [ErlFile] = mad_compile:erl_files(SrcDir).
  22. app_src_files(Config) ->
  23. DataDir = get_value(data_dir, Config),
  24. SrcDir = filename:join([DataDir, "deps", "one", "src"]),
  25. AppSrcFile = filename:join(SrcDir, "one.app.src"),
  26. [AppSrcFile] = mad_compile:app_src_files(SrcDir).
  27. is_app_src(_) ->
  28. false = mad_compile:is_app_src("/path/to/file.erl"),
  29. true = mad_compile:is_app_src("/path/to/file.app.src").
  30. app_src_to_app(_) ->
  31. "file.app" = mad_compile:app_src_to_app("/path/to/file.app.src").
  32. erl_to_beam(_) ->
  33. "/path/to/ebin/file.beam" = mad_compile:erl_to_beam("/path/to/ebin",
  34. "/path/to/file.erl").
  35. deps(Config) ->
  36. DataDir = get_value(data_dir, Config),
  37. Deps = [{one, "", {}}, {two, "", {}}],
  38. ok = mad_compile:deps(DataDir, Config, "rebar.config", Deps),
  39. pong = one:ping(),
  40. pong = two:ping(),
  41. ok = application:load(one),
  42. ok = application:load(two),
  43. {ok, [one]} = application:get_key(one, modules),
  44. {ok, [two]} = application:get_key(two, modules),
  45. ok = one:test_inc_hrl(),
  46. ok = one:test_src_hrl(),
  47. ok = two:test_inc_hrl(),
  48. ok = two:test_src_hrl().
  49. app(Config) ->
  50. DataDir = get_value(data_dir, Config),
  51. ok = mad_compile:app(DataDir, Config, "rebar.config"),
  52. pong = three:ping(),
  53. ok = application:load(three),
  54. {ok, [three]} = application:get_key(three, modules),
  55. ok = three:test_inc_hrl(),
  56. ok = three:test_src_hrl().
  57. is_compiled(Config) ->
  58. DataDir = get_value(data_dir, Config),
  59. SrcDir = filename:join([DataDir, "deps", "one", "src"]),
  60. EbinDir = filename:join([SrcDir, "..", "ebin"]),
  61. BeamFile1 = filename:join(EbinDir, "x.beam"),
  62. BeamFile2 = filename:join(EbinDir, "one.beam"),
  63. false = mad_compile:is_compiled(BeamFile1, filename:join(SrcDir, "x.erl")),
  64. true = mad_compile:is_compiled(BeamFile2, filename:join(SrcDir, "one.erl")).