mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Fix #252 (Reported-by: Maxim-Vladimirsky)
This commit is contained in:
parent
b9c6888883
commit
e6165c7146
2 changed files with 20 additions and 27 deletions
|
@ -132,12 +132,14 @@ eunit(Config, _AppFile) ->
|
||||||
ModuleBeamFiles = BeamFiles ++ OtherBeamFiles,
|
ModuleBeamFiles = BeamFiles ++ OtherBeamFiles,
|
||||||
Modules = [rebar_utils:beam_to_mod(?EUNIT_DIR, N) || N <- ModuleBeamFiles],
|
Modules = [rebar_utils:beam_to_mod(?EUNIT_DIR, N) || N <- ModuleBeamFiles],
|
||||||
SrcModules = [rebar_utils:erl_to_mod(M) || M <- SrcErls],
|
SrcModules = [rebar_utils:erl_to_mod(M) || M <- SrcErls],
|
||||||
|
Suites = get_suites(),
|
||||||
|
FilteredModules = filtered_modules(Modules, Suites),
|
||||||
|
|
||||||
{ok, CoverLog} = cover_init(Config, ModuleBeamFiles),
|
{ok, CoverLog} = cover_init(Config, ModuleBeamFiles),
|
||||||
|
|
||||||
StatusBefore = status_before_eunit(),
|
StatusBefore = status_before_eunit(),
|
||||||
EunitResult = perform_eunit(Config, Modules),
|
EunitResult = perform_eunit(Config, FilteredModules),
|
||||||
perform_cover(Config, Modules, SrcModules),
|
perform_cover(Config, FilteredModules, SrcModules),
|
||||||
|
|
||||||
cover_close(CoverLog),
|
cover_close(CoverLog),
|
||||||
|
|
||||||
|
@ -173,10 +175,16 @@ eunit_dir() ->
|
||||||
ebin_dir() ->
|
ebin_dir() ->
|
||||||
filename:join(rebar_utils:get_cwd(), "ebin").
|
filename:join(rebar_utils:get_cwd(), "ebin").
|
||||||
|
|
||||||
perform_eunit(Config, Modules) ->
|
get_suites() ->
|
||||||
%% suite defined, so only specify the module that relates to the
|
Suites = rebar_utils:get_deprecated_global(suite, suites, [], "soon"),
|
||||||
%% suite (if any). Suite can be a comma seperated list of modules to run.
|
[list_to_atom(Suite) || Suite <- string:tokens(Suites, ",")].
|
||||||
Suite = rebar_config:get_global(suite, undefined),
|
|
||||||
|
filtered_modules(Modules, []) ->
|
||||||
|
Modules;
|
||||||
|
filtered_modules(Modules, Suites) ->
|
||||||
|
[M || M <- Modules, lists:member(M, Suites)].
|
||||||
|
|
||||||
|
perform_eunit(Config, FilteredModules) ->
|
||||||
EunitOpts = get_eunit_opts(Config),
|
EunitOpts = get_eunit_opts(Config),
|
||||||
|
|
||||||
%% Move down into ?EUNIT_DIR while we run tests so any generated files
|
%% Move down into ?EUNIT_DIR while we run tests so any generated files
|
||||||
|
@ -184,19 +192,13 @@ perform_eunit(Config, Modules) ->
|
||||||
Cwd = rebar_utils:get_cwd(),
|
Cwd = rebar_utils:get_cwd(),
|
||||||
ok = file:set_cwd(?EUNIT_DIR),
|
ok = file:set_cwd(?EUNIT_DIR),
|
||||||
|
|
||||||
EunitResult = perform_eunit(EunitOpts, Modules, Suite),
|
EunitResult = (catch eunit:test(FilteredModules, EunitOpts)),
|
||||||
|
|
||||||
%% Return to original working dir
|
%% Return to original working dir
|
||||||
ok = file:set_cwd(Cwd),
|
ok = file:set_cwd(Cwd),
|
||||||
|
|
||||||
EunitResult.
|
EunitResult.
|
||||||
|
|
||||||
perform_eunit(EunitOpts, Modules, undefined) ->
|
|
||||||
(catch eunit:test(Modules, EunitOpts));
|
|
||||||
perform_eunit(EunitOpts, _Modules, Suites) ->
|
|
||||||
(catch eunit:test([list_to_atom(Suite) ||
|
|
||||||
Suite <- string:tokens(Suites, ",")], EunitOpts)).
|
|
||||||
|
|
||||||
get_eunit_opts(Config) ->
|
get_eunit_opts(Config) ->
|
||||||
%% Enable verbose in eunit if so requested..
|
%% Enable verbose in eunit if so requested..
|
||||||
BaseOpts = case rebar_config:is_verbose() of
|
BaseOpts = case rebar_config:is_verbose() of
|
||||||
|
@ -260,15 +262,7 @@ perform_cover(true, Config, BeamFiles, SrcModules) ->
|
||||||
|
|
||||||
cover_analyze(_Config, [], _SrcModules) ->
|
cover_analyze(_Config, [], _SrcModules) ->
|
||||||
ok;
|
ok;
|
||||||
cover_analyze(Config, Modules, SrcModules) ->
|
cover_analyze(Config, FilteredModules, SrcModules) ->
|
||||||
%% suite can be a comma seperated list of modules to test
|
|
||||||
Suite = [list_to_atom(S) ||
|
|
||||||
S <- string:tokens(rebar_config:get_global(suite, ""), ",")],
|
|
||||||
FilteredModules = case Suite of
|
|
||||||
[] -> Modules;
|
|
||||||
_ -> [M || M <- Modules, lists:member(M, Suite)]
|
|
||||||
end,
|
|
||||||
|
|
||||||
%% Generate coverage info for all the cover-compiled modules
|
%% Generate coverage info for all the cover-compiled modules
|
||||||
Coverage = lists:flatten([cover_analyze_mod(M) || M <- FilteredModules]),
|
Coverage = lists:flatten([cover_analyze_mod(M) || M <- FilteredModules]),
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
deprecated/3, deprecated/4,
|
deprecated/3, deprecated/4,
|
||||||
expand_env_variable/3,
|
expand_env_variable/3,
|
||||||
vcs_vsn/2,
|
vcs_vsn/2,
|
||||||
get_deprecated_global/3,
|
get_deprecated_global/3, get_deprecated_global/4,
|
||||||
get_deprecated_list/4, get_deprecated_list/5,
|
get_deprecated_list/4, get_deprecated_list/5,
|
||||||
get_deprecated_local/4, get_deprecated_local/5,
|
get_deprecated_local/4, get_deprecated_local/5,
|
||||||
delayed_halt/1]).
|
delayed_halt/1]).
|
||||||
|
@ -243,10 +243,10 @@ get_deprecated_global(OldOpt, NewOpt, When) ->
|
||||||
|
|
||||||
get_deprecated_global(OldOpt, NewOpt, Default, When) ->
|
get_deprecated_global(OldOpt, NewOpt, Default, When) ->
|
||||||
case rebar_config:get_global(NewOpt, Default) of
|
case rebar_config:get_global(NewOpt, Default) of
|
||||||
undefined ->
|
Default ->
|
||||||
case rebar_config:get_global(OldOpt, Default) of
|
case rebar_config:get_global(OldOpt, Default) of
|
||||||
undefined ->
|
Default ->
|
||||||
undefined;
|
Default;
|
||||||
Old ->
|
Old ->
|
||||||
deprecated(OldOpt, NewOpt, When),
|
deprecated(OldOpt, NewOpt, When),
|
||||||
Old
|
Old
|
||||||
|
@ -255,7 +255,6 @@ get_deprecated_global(OldOpt, NewOpt, Default, When) ->
|
||||||
New
|
New
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
get_deprecated_list(Config, OldOpt, NewOpt, When) ->
|
get_deprecated_list(Config, OldOpt, NewOpt, When) ->
|
||||||
get_deprecated_list(Config, OldOpt, NewOpt, undefined, When).
|
get_deprecated_list(Config, OldOpt, NewOpt, undefined, When).
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue