From d6a34f9d68b962205170c78dd1ef7b97f8475180 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Thu, 22 Dec 2016 00:48:49 -0800 Subject: don't filter eunit test modules based on file extension stops the eunit provider from filtering out test modules based on the file extension. previously, it was hardcoded to expect all test files ended in `.erl`. this change allows for endings like `.lfe` and `.beam` --- src/rebar_prv_eunit.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/rebar_prv_eunit.erl b/src/rebar_prv_eunit.erl index a9db12e..f65f700 100644 --- a/src/rebar_prv_eunit.erl +++ b/src/rebar_prv_eunit.erl @@ -198,8 +198,8 @@ dedupe_tests({AppMods, TestMods}) -> %% for each modules in TestMods create a test if there is not a module %% in AppMods that will trigger it F = fun(Mod) -> - M = filename:basename(Mod, ".erl"), - MatchesTest = fun(Dir) -> filename:basename(Dir, ".erl") ++ "_tests" == M end, + M = filename:rootname(filename:basename(Mod)), + MatchesTest = fun(Dir) -> filename:rootname(filename:basename(Dir)) ++ "_tests" == M end, case lists:any(MatchesTest, AppMods) of false -> {true, {module, list_to_atom(M)}}; true -> false -- cgit v1.1 From 5b3526518689eef8765a9303d43408864200b5d8 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Fri, 23 Dec 2016 10:47:16 -0800 Subject: eunit: remove application modules from the modules eligible to test application modules will be added to the eunit test set automatically, no need to consider them for inclusion in the test set separately --- src/rebar_prv_eunit.erl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/rebar_prv_eunit.erl b/src/rebar_prv_eunit.erl index f65f700..7d44137 100644 --- a/src/rebar_prv_eunit.erl +++ b/src/rebar_prv_eunit.erl @@ -195,17 +195,18 @@ gather_src([Dir|Rest], Regex, Srcs) -> gather_src(Rest, Regex, Srcs ++ rebar_utils:find_files(Dir, Regex, true)). dedupe_tests({AppMods, TestMods}) -> + UniqueTestMods = lists:usort(TestMods) -- AppMods, %% for each modules in TestMods create a test if there is not a module %% in AppMods that will trigger it - F = fun(Mod) -> - M = filename:rootname(filename:basename(Mod)), - MatchesTest = fun(Dir) -> filename:rootname(filename:basename(Dir)) ++ "_tests" == M end, + F = fun(TestMod) -> + M = filename:rootname(filename:basename(TestMod)), + MatchesTest = fun(AppMod) -> filename:rootname(filename:basename(AppMod)) ++ "_tests" == M end, case lists:any(MatchesTest, AppMods) of false -> {true, {module, list_to_atom(M)}}; true -> false end end, - lists:usort(rebar_utils:filtermap(F, TestMods)). + rebar_utils:filtermap(F, UniqueTestMods). inject_eunit_state(State, {ok, Tests}) -> Apps = rebar_state:project_apps(State), -- cgit v1.1