diff options
author | alisdair sullivan <alisdairsullivan@yahoo.ca> | 2015-01-08 13:08:27 -0800 |
---|---|---|
committer | alisdair sullivan <alisdairsullivan@yahoo.ca> | 2015-01-08 14:10:21 -0800 |
commit | 853efc50770b9c79795184575420212da7f7ddf7 (patch) | |
tree | bea70a7da800eb14ec3f3f6b58b82229084f4eee | |
parent | 99732ae4f37c406b9c2772b5de5013ee13c9099a (diff) |
exclude `_checkouts` from directories to be precompiled for
`common_test` and `eunit` providers
-rw-r--r-- | src/rebar_prv_common_test.erl | 15 | ||||
-rw-r--r-- | src/rebar_prv_eunit.erl | 17 |
2 files changed, 27 insertions, 5 deletions
diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl index 2cdef33..46d3240 100644 --- a/src/rebar_prv_common_test.erl +++ b/src/rebar_prv_common_test.erl @@ -38,7 +38,7 @@ do(State) -> {RawOpts, _} = rebar_state:command_parsed_args(State), {InDirs, OutDir} = split_ct_dirs(State, RawOpts), Opts = transform_opts(RawOpts), - ProjectApps = rebar_state:project_apps(State), + TestApps = filter_checkouts(rebar_state:project_apps(State)), ok = create_dirs(Opts), ?DEBUG("Compiling Common Test suites in: ~p", [OutDir]), lists:foreach(fun(App) -> @@ -50,7 +50,7 @@ do(State) -> %% and `{src_dirs, "test"}` TestState = test_state(S, InDirs, OutDir), ok = rebar_erlc_compiler:compile(TestState, AppDir) - end, ProjectApps), + end, TestApps), Path = code:get_path(), true = code:add_patha(OutDir), CTOpts = resolve_ct_opts(State, Opts, OutDir), @@ -253,6 +253,17 @@ parse_term(String) -> Term end. +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); + false -> filter_checkouts(Rest, [App|Acc]) + end. + create_dirs(Opts) -> LogDir = proplists:get_value(logdir, Opts), ensure_dir([LogDir]), diff --git a/src/rebar_prv_eunit.erl b/src/rebar_prv_eunit.erl index 7db11a3..499a04f 100644 --- a/src/rebar_prv_eunit.erl +++ b/src/rebar_prv_eunit.erl @@ -37,7 +37,7 @@ do(State) -> ?INFO("Performing EUnit tests...", []), {RawOpts, _} = rebar_state:command_parsed_args(State), Opts = transform_opts(RawOpts, State), - ProjectApps = rebar_state:project_apps(State), + TestApps = filter_checkouts(rebar_state:project_apps(State)), OutDir = case proplists:get_value(outdir, Opts, undefined) of undefined -> filename:join([rebar_state:dir(State), ec_file:insecure_mkdtemp()]); @@ -53,12 +53,12 @@ do(State) -> %% and `{src_dirs, "test"}` TestState = first_files(test_opts(S, OutDir)), ok = rebar_erlc_compiler:compile(TestState, AppDir) - end, ProjectApps), + end, TestApps), Path = code:get_path(), true = code:add_patha(OutDir), EUnitOpts = resolve_eunit_opts(State, Opts), AppsToTest = [{application, erlang:binary_to_atom(rebar_app_info:name(App), unicode)} - || App <- ProjectApps], + || App <- TestApps], Result = eunit:test(AppsToTest, EUnitOpts), true = code:set_path(Path), case handle_results(Result) of @@ -93,6 +93,17 @@ transform_opts([{outdir, Path}|Rest], State, Acc) -> transform_opts([{Key, Val}|Rest], State, Acc) -> transform_opts(Rest, State, [{Key, Val}|Acc]). +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); + false -> filter_checkouts(Rest, [App|Acc]) + end. + test_opts(State, TmpDir) -> ErlOpts = rebar_state:get(State, eunit_compile_opts, []) ++ rebar_utils:erl_opts(State), |