2016-03-02 12:40:32 +00:00
|
|
|
From: Peter Lemenkov <lemenkov@gmail.com>
|
|
|
|
Date: Wed, 2 Mar 2016 15:10:20 +0300
|
|
|
|
Subject: [PATCH] Remove pre-R15B02 workaround
|
|
|
|
|
|
|
|
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
|
|
|
|
|
|
|
|
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
|
2016-09-01 14:52:35 +00:00
|
|
|
index f4d7b76..63f8c31 100644
|
2016-03-02 12:40:32 +00:00
|
|
|
--- a/src/rebar_eunit.erl
|
|
|
|
+++ b/src/rebar_eunit.erl
|
2016-09-01 14:52:35 +00:00
|
|
|
@@ -436,18 +436,6 @@ get_beam_test_exports(ModuleStr) ->
|
2016-03-02 12:40:32 +00:00
|
|
|
end.
|
|
|
|
|
|
|
|
make_test_primitives(RawTests) ->
|
|
|
|
- %% Use {test,M,F} and {generator,M,F} if at least R15B02. Otherwise,
|
|
|
|
- %% use eunit_test:function_wrapper/2 fallback.
|
|
|
|
- %% eunit_test:function_wrapper/2 was renamed to eunit_test:mf_wrapper/2
|
|
|
|
- %% in R15B02; use that as >= R15B02 check.
|
|
|
|
- %% TODO: remove fallback and use only {test,M,F} and {generator,M,F}
|
|
|
|
- %% primitives once at least R15B02 is required.
|
|
|
|
- {module, eunit_test} = code:ensure_loaded(eunit_test),
|
|
|
|
- MakePrimitive = case erlang:function_exported(eunit_test, mf_wrapper, 2) of
|
|
|
|
- true -> fun eunit_primitive/3;
|
|
|
|
- false -> fun pre15b02_eunit_primitive/3
|
|
|
|
- end,
|
|
|
|
-
|
|
|
|
?CONSOLE(" Running test function(s):~n", []),
|
|
|
|
F = fun({M, F2}, Acc) ->
|
|
|
|
?CONSOLE(" ~p:~p/0~n", [M, F2]),
|
2016-09-01 14:52:35 +00:00
|
|
|
@@ -456,23 +444,15 @@ make_test_primitives(RawTests) ->
|
2016-03-02 12:40:32 +00:00
|
|
|
case re:run(FNameStr, "_test_") of
|
|
|
|
nomatch ->
|
|
|
|
%% Normal test
|
|
|
|
- MakePrimitive(test, M, F2);
|
|
|
|
+ {test, M, F2};
|
|
|
|
_ ->
|
|
|
|
%% Generator
|
|
|
|
- MakePrimitive(generator, M, F2)
|
|
|
|
+ {generator, M, F2}
|
|
|
|
end,
|
2016-09-01 14:52:35 +00:00
|
|
|
[eunit_module_suite(M, NewFunction)|Acc]
|
2016-03-02 12:40:32 +00:00
|
|
|
end,
|
|
|
|
lists:foldl(F, [], RawTests).
|
|
|
|
|
|
|
|
-eunit_primitive(Type, M, F) ->
|
|
|
|
- {Type, M, F}.
|
|
|
|
-
|
|
|
|
-pre15b02_eunit_primitive(test, M, F) ->
|
|
|
|
- eunit_test:function_wrapper(M, F);
|
|
|
|
-pre15b02_eunit_primitive(generator, M, F) ->
|
|
|
|
- {generator, eunit_test:function_wrapper(M, F)}.
|
|
|
|
-
|
2016-09-01 14:52:35 +00:00
|
|
|
% Add a test group for eunit_surefire to be able to deduce the testsuite.
|
|
|
|
% Calling eunit:test({module, M}) does exactly this as well.
|
|
|
|
eunit_module_suite(M, X) ->
|