-
Notifications
You must be signed in to change notification settings - Fork 82
/
edts-escript
executable file
·34 lines (30 loc) · 989 Bytes
/
edts-escript
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
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -sname edts-helper
main(["release", ReleaseConfig]) ->
{ok, Conf} = file:consult(ReleaseConfig),
{ok, Spec} = reltool:get_target_spec(Conf),
reltool:eval_target_spec(Spec, code:root_dir(), "rel");
main(["eunit", Ebin|Deps]) ->
Beams = filelib:wildcard(filename:join(Ebin, "*.beam")),
[true = code:add_path(D) || D <- [Ebin|Deps]],
[test_one(B) || B <- Beams];
main(Args) ->
io:format("Unknown Args: ~p~n", [Args]),
io:format("release ReleaseConfig~n"),
io:format("eunit EbinPathToTest Deps0 Deps1 Deps2~n"),
halt(1).
test_one(Path0) ->
Mod = list_to_atom(filename:basename(Path0, ".beam")),
MI = Mod:module_info(exports),
case proplists:lookup(test, MI) of
{test, 0} ->
io:format("Eunit ~s:~n", [Path0]),
case eunit:test(Mod) of
ok -> ok;
error ->
halt(2)
end;
none ->
ok
end.