You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 line
1.3 KiB

  1. -module(eunit_rt).
  2. -export([files/0, run/1]).
  3. -include_lib("eunit/include/eunit.hrl").
  4. files() ->
  5. [{create, "ebin/foo.app", app(foo)},
  6. {copy, "../../rebar", "rebar"},
  7. {copy, "src", "src"},
  8. {copy, "eunit_src", "eunit_src"},
  9. {copy,
  10. "rebar-eunit_compile_opts.config",
  11. "rebar-eunit_compile_opts.config"}].
  12. run(_Dir) ->
  13. ifdef_test(),
  14. eunit_compile_opts_test(),
  15. ok.
  16. ifdef_test() ->
  17. {ok, Output} = retest:sh("./rebar -v eunit"),
  18. ?assert(check_output(Output, "foo_test")),
  19. ?assertMatch({ok, _}, retest:sh("./rebar clean")).
  20. eunit_compile_opts_test() ->
  21. {ok, Output} =
  22. retest:sh("./rebar -v -C rebar-eunit_compile_opts.config eunit"),
  23. ?assert(check_output(Output, "bar_test")),
  24. ?assertMatch(
  25. {ok, _},
  26. retest:sh("./rebar -C rebar-eunit_compile_opts.config clean")).
  27. check_output(Output, Target) ->
  28. lists:any(fun(Line) ->
  29. string:str(Line, Target) > 0
  30. end, Output).
  31. %%
  32. %% Generate the contents of a simple .app file
  33. %%
  34. app(Name) ->
  35. App = {application, Name,
  36. [{description, atom_to_list(Name)},
  37. {vsn, "1"},
  38. {modules, []},
  39. {registered, []},
  40. {applications, [kernel, stdlib]}]},
  41. io_lib:format("~p.\n", [App]).