summaryrefslogtreecommitdiff
path: root/inttest/eunit/eunit_rt.erl
blob: 47f3331e768b8ccead66903c46c78a52818ba21d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-module(eunit_rt).
-export([files/0, run/1]).

-include_lib("eunit/include/eunit.hrl").

files() ->
    [{create, "ebin/foo.app", app(foo)},
     {copy, "../../rebar", "rebar"},
     {copy, "src", "src"},
     {copy, "eunit_src", "eunit_src"},
     {copy,
      "rebar-eunit_compile_opts.config",
      "rebar-eunit_compile_opts.config"}].

run(_Dir) ->
    ifdef_test(),
    eunit_compile_opts_test(),
    ok.

ifdef_test() ->
    {ok, Output} = retest:sh("./rebar -v eunit"),
    ?assert(check_output(Output, "foo_test")),
    ?assertMatch({ok, _}, retest:sh("./rebar clean")).

eunit_compile_opts_test() ->
    {ok, Output} =
        retest:sh("./rebar -v -C rebar-eunit_compile_opts.config eunit"),
    ?assert(check_output(Output, "bar_test")),
    ?assertMatch(
       {ok, _},
       retest:sh("./rebar -C rebar-eunit_compile_opts.config clean")).

check_output(Output, Target) ->
    lists:any(fun(Line) ->
                      string:str(Line, Target) > 0
              end, Output).

%%
%% Generate the contents of a simple .app file
%%
app(Name) ->
    App = {application, Name,
           [{description, atom_to_list(Name)},
            {vsn, "1"},
            {modules, []},
            {registered, []},
            {applications, [kernel, stdlib]}]},
    io_lib:format("~p.\n", [App]).