mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Use R15B02 EUnit {test,M,F} primitive as suggested by Richard Carlsson
This commit is contained in:
parent
29492dd0e8
commit
e0bc55db33
3 changed files with 21 additions and 15 deletions
|
@ -1,2 +1,3 @@
|
||||||
|
|
||||||
|
rebar_eunit.erl:351: Call to missing or unexported function eunit_test:function_wrapper/2
|
||||||
rebar_utils.erl:163: Call to missing or unexported function escript:foldl/3
|
rebar_utils.erl:163: Call to missing or unexported function escript:foldl/3
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
[{"(XC - UC) || (XU - X - B
|
[{"(XC - UC) || (XU - X - B
|
||||||
- (\"escript\":\"foldl\"/\"3\")
|
- (\"escript\":\"foldl\"/\"3\")
|
||||||
- (\"eunit_test\":\"function_wrapper\"/\"2\")
|
- (\"eunit_test\":\"function_wrapper\"/\"2\")
|
||||||
- (\"eunit_test\":\"mf_wrapper\"/\"2\")
|
|
||||||
- (\"abnfc\":\"file\"/\"2\")
|
- (\"abnfc\":\"file\"/\"2\")
|
||||||
- (\"erlydtl\":\"compile\"/\"3\")
|
- (\"erlydtl\":\"compile\"/\"3\")
|
||||||
- (\"lfe_comp\":\"file\"/\"2\")
|
- (\"lfe_comp\":\"file\"/\"2\")
|
||||||
|
|
|
@ -233,7 +233,7 @@ get_matching_tests(Config, Modules) ->
|
||||||
[] ->
|
[] ->
|
||||||
[];
|
[];
|
||||||
RawTests ->
|
RawTests ->
|
||||||
make_test_wrappers(RawTests)
|
make_test_primitives(RawTests)
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -312,13 +312,17 @@ get_beam_test_exports(ModuleStr) ->
|
||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
make_test_wrappers(RawTests) ->
|
make_test_primitives(RawTests) ->
|
||||||
%% eunit_test:function_wrapper/2 was renamed to mf_wrapper/2 in R15B02
|
%% Use {test,M,F} and {generator,M,F} if at least R15B02. Otherwise,
|
||||||
%% TODO: remove check/fallback once at least R15B02 is required
|
%% 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),
|
{module, eunit_test} = code:ensure_loaded(eunit_test),
|
||||||
WrapperFun = case erlang:function_exported(eunit_test, mf_wrapper, 2) of
|
MakePrimitive = case erlang:function_exported(eunit_test, mf_wrapper, 2) of
|
||||||
true -> fun eunit_test:mf_wrapper/2;
|
true -> fun eunit_primitive/3;
|
||||||
false -> fun eunit_test:function_wrapper/2
|
false -> fun pre15b02_eunit_primitive/3
|
||||||
end,
|
end,
|
||||||
|
|
||||||
?CONSOLE(" Running test function(s):~n", []),
|
?CONSOLE(" Running test function(s):~n", []),
|
||||||
|
@ -329,20 +333,22 @@ make_test_wrappers(RawTests) ->
|
||||||
case re:run(FNameStr, "_test_") of
|
case re:run(FNameStr, "_test_") of
|
||||||
nomatch ->
|
nomatch ->
|
||||||
%% Normal test
|
%% Normal test
|
||||||
eunit_test(WrapperFun, M, F2);
|
MakePrimitive(test, M, F2);
|
||||||
_ ->
|
_ ->
|
||||||
%% Generator
|
%% Generator
|
||||||
eunit_generator(WrapperFun, M, F2)
|
MakePrimitive(generator, M, F2)
|
||||||
end,
|
end,
|
||||||
[NewFunction|Acc]
|
[NewFunction|Acc]
|
||||||
end,
|
end,
|
||||||
lists:foldl(F, [], RawTests).
|
lists:foldl(F, [], RawTests).
|
||||||
|
|
||||||
eunit_test(WrapperFun, M, F) ->
|
eunit_primitive(Type, M, F) ->
|
||||||
WrapperFun(M, F).
|
{Type, M, F}.
|
||||||
|
|
||||||
eunit_generator(WrapperFun, M, F) ->
|
pre15b02_eunit_primitive(test, M, F) ->
|
||||||
{generator, WrapperFun(M, F)}.
|
eunit_test:function_wrapper(M, F);
|
||||||
|
pre15b02_eunit_primitive(generator, M, F) ->
|
||||||
|
{generator, eunit_test:function_wrapper(M, F)}.
|
||||||
|
|
||||||
%%
|
%%
|
||||||
%% == run tests ==
|
%% == run tests ==
|
||||||
|
|
Loading…
Reference in a new issue