summaryrefslogtreecommitdiff
path: root/src/rebar_prv_eunit.erl
diff options
context:
space:
mode:
authoralisdair sullivan <alisdairsullivan@yahoo.ca>2015-03-08 13:41:44 -0700
committeralisdair sullivan <alisdairsullivan@yahoo.ca>2015-03-08 13:41:44 -0700
commitb0300f1b2f1c366510463e3a110694e225f69ae3 (patch)
tree63fada6a4f9828b9b6d839848c76cc37e738b3d3 /src/rebar_prv_eunit.erl
parentab84fc89ccf7fbbff8457afefdc301e37de6a6c9 (diff)
symlink extra test dirs and compile from there instead of from
root project
Diffstat (limited to 'src/rebar_prv_eunit.erl')
-rw-r--r--src/rebar_prv_eunit.erl17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/rebar_prv_eunit.erl b/src/rebar_prv_eunit.erl
index 1540471..8763344 100644
--- a/src/rebar_prv_eunit.erl
+++ b/src/rebar_prv_eunit.erl
@@ -140,15 +140,22 @@ compile_tests(State, TestApps) ->
ec_cnv:to_list(rebar_app_info:out_dir(AppInfo)))
end,
lists:foreach(F, TestApps),
- compile_bare_tests(State, TestApps).
+ case filelib:is_dir(filename:join([rebar_dir:get_cwd(), "test"])) of
+ true -> compile_bare_tests(State, TestApps);
+ false -> ok
+ end.
compile_bare_tests(State, TestApps) ->
F = fun(App) -> rebar_app_info:dir(App) == rebar_dir:get_cwd() end,
case lists:filter(F, TestApps) of
- %% compile just the `test` directory of the base dir
- [] -> rebar_erlc_compiler:compile(replace_src_dirs(State),
- rebar_dir:get_cwd(),
- filename:join([rebar_dir:base_dir(State), "ebin"]));
+ %% compile and link just the `test` directory of the base dir
+ [] ->
+ Source = filename:join([rebar_dir:get_cwd(), "test"]),
+ Target = filename:join([rebar_dir:base_dir(State), "test"]),
+ ok = rebar_file_utils:symlink_or_copy(Source, Target),
+ rebar_erlc_compiler:compile(replace_src_dirs(State),
+ rebar_dir:base_dir(State),
+ filename:join([rebar_dir:base_dir(State), "ebin"]));
%% already compiled `./test` so do nothing
_ -> ok
end.