Skip to content

Commit 18aeb78

Browse files
author
José Valim
committed
Exit with proper test code on test_erlang, closes #2313
1 parent 83ccde4 commit 18aeb78

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,19 @@ release_docs: docs
149149

150150
test: test_erlang test_elixir
151151

152-
test_erlang: compile
152+
TEST_ERL = lib/elixir/test/erlang
153+
TEST_EBIN = lib/elixir/test/ebin
154+
TEST_ERLS = $(addprefix $(TEST_EBIN)/, $(addsuffix .beam, $(basename $(notdir $(wildcard $(TEST_ERL)/*.erl)))))
155+
156+
test_erlang: compile $(TEST_ERLS)
153157
@ echo "==> elixir (eunit)"
154-
$(Q) mkdir -p lib/elixir/test/ebin
155-
$(Q) $(ERLC) -pa lib/elixir/ebin -o lib/elixir/test/ebin lib/elixir/test/erlang/*.erl
156-
$(Q) $(ERL) -pa lib/elixir/test/ebin -s test_helper test -s erlang halt;
158+
$(Q) $(ERL) -pa $(TEST_EBIN) -s test_helper test;
157159
@ echo ""
158160

161+
$(TEST_EBIN)/%.beam: $(TEST_ERL)/%.erl
162+
$(Q) mkdir -p $(TEST_EBIN)
163+
$(Q) $(ERLC) -o $(TEST_EBIN) $<
164+
159165
test_elixir: test_stdlib test_ex_unit test_doc_test test_mix test_eex test_iex
160166

161167
test_doc_test: compile

lib/elixir/test/erlang/test_helper.erl

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
-module(test_helper).
22
-include("elixir.hrl").
33
-export([test/0, run_and_remove/2, throw_elixir/1, throw_erlang/1]).
4+
-define(TESTS, [
5+
atom_test,
6+
control_test,
7+
function_test,
8+
match_test,
9+
module_test,
10+
operators_test,
11+
string_test,
12+
tokenizer_test
13+
]).
414

515
test() ->
616
application:start(elixir),
7-
eunit:test([
8-
atom_test,
9-
control_test,
10-
function_test,
11-
match_test,
12-
module_test,
13-
operators_test,
14-
string_test,
15-
tokenizer_test
16-
]).
17+
case eunit:test(?TESTS) of
18+
error -> erlang:halt(1);
19+
_Res -> erlang:halt(0)
20+
end.
1721

1822
% Execute a piece of code and purge given modules right after
1923
run_and_remove(Fun, Modules) ->

0 commit comments

Comments
 (0)