summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralisdair sullivan <alisdairsullivan@yahoo.ca>2015-03-23 22:24:33 -0700
committeralisdair sullivan <alisdairsullivan@yahoo.ca>2015-03-24 22:01:28 -0700
commit044b6580e75a33fed26303eebb5a3648f8b022d3 (patch)
tree3c29d61f91c3763f284627aa1d4a117af64be16c
parentc5bc19b021da907e36135c174d85896be3043218 (diff)
filter checkapps via `rebar_app_info:is_checkout` rather than
matching directory paths
-rw-r--r--src/rebar_prv_eunit.erl6
-rw-r--r--test/rebar_eunit_SUITE.erl24
2 files changed, 24 insertions, 6 deletions
diff --git a/src/rebar_prv_eunit.erl b/src/rebar_prv_eunit.erl
index 8ac0187..b196df8 100644
--- a/src/rebar_prv_eunit.erl
+++ b/src/rebar_prv_eunit.erl
@@ -142,10 +142,8 @@ filter_checkouts(Apps) -> filter_checkouts(Apps, []).
filter_checkouts([], Acc) -> lists:reverse(Acc);
filter_checkouts([App|Rest], Acc) ->
- AppDir = filename:absname(rebar_app_info:dir(App)),
- CheckoutsDir = filename:absname("_checkouts"),
- case lists:prefix(CheckoutsDir, AppDir) of
- true -> filter_checkouts(Rest, Acc);
+ case rebar_app_info:is_checkout(App) of
+ true -> filter_checkouts(Rest, Acc);
false -> filter_checkouts(Rest, [App|Acc])
end.
diff --git a/test/rebar_eunit_SUITE.erl b/test/rebar_eunit_SUITE.erl
index 33df773..4ec92f2 100644
--- a/test/rebar_eunit_SUITE.erl
+++ b/test/rebar_eunit_SUITE.erl
@@ -219,6 +219,15 @@ test_single_app_flag(Config) ->
Vsn2,
[kernel, stdlib]),
+ BareSuite = io_lib:format("-module(all_tests).\n"
+ "-compile(export_all).\n"
+ "-include_lib(\"eunit/include/eunit.hrl\").\n"
+ "some_test_() -> ?_assert(true).\n"
+ "define_test_() -> ?_assertEqual(true, ?some_define).\n", []),
+ FileName = filename:join([AppDir, "test", "all_tests.erl"]),
+ ok = filelib:ensure_dir(FileName),
+ ok = ec_file:write(FileName, BareSuite),
+
RebarConfig = [{erl_opts, [{d, some_define}]}],
rebar_test_utils:run_and_check(Config,
RebarConfig,
@@ -228,7 +237,8 @@ test_single_app_flag(Config) ->
Suite1 = list_to_atom("not_a_real_src_" ++ Name1 ++ "_tests"),
{module, Suite1} = code:ensure_loaded(Suite1),
Suite2 = list_to_atom("not_a_real_src_" ++ Name2 ++ "_tests"),
- {error, nofile} = code:ensure_loaded(Suite2).
+ {error, nofile} = code:ensure_loaded(Suite2),
+ {error, nofile} = code:ensure_loaded(all_tests).
test_multiple_app_flag(Config) ->
AppDir = ?config(apps, Config),
@@ -246,6 +256,15 @@ test_multiple_app_flag(Config) ->
Vsn2,
[kernel, stdlib]),
+ BareSuite = io_lib:format("-module(all_tests).\n"
+ "-compile(export_all).\n"
+ "-include_lib(\"eunit/include/eunit.hrl\").\n"
+ "some_test_() -> ?_assert(true).\n"
+ "define_test_() -> ?_assertEqual(true, ?some_define).\n", []),
+ FileName = filename:join([AppDir, "test", "all_tests.erl"]),
+ ok = filelib:ensure_dir(FileName),
+ ok = ec_file:write(FileName, BareSuite),
+
RebarConfig = [{erl_opts, [{d, some_define}]}],
rebar_test_utils:run_and_check(Config,
RebarConfig,
@@ -255,7 +274,8 @@ test_multiple_app_flag(Config) ->
Suite1 = list_to_atom("not_a_real_src_" ++ Name1 ++ "_tests"),
{module, Suite1} = code:ensure_loaded(Suite1),
Suite2 = list_to_atom("not_a_real_src_" ++ Name2 ++ "_tests"),
- {module, Suite2} = code:ensure_loaded(Suite2).
+ {module, Suite2} = code:ensure_loaded(Suite2),
+ {error, nofile} = code:ensure_loaded(all_tests).
test_nonexistent_app_flag(Config) ->
AppDir = ?config(apps, Config),