summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMotiejus Jakštys <desired.mta@gmail.com>2012-07-02 12:14:05 +0300
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2012-07-02 18:46:00 +0200
commitad2f30ccb90fd160a318d10e25e22c6fd4ce2537 (patch)
treefa3a06ef1bb127859cd9539aaaf8454c95c0e6b0 /src
parent394c0f43f88ce7fba9f16f634fd9d006cf42e949 (diff)
Fix cover crash if src_dirs is not default
Make sure files from erl_opts->src_dirs are copied to .eunit for cover inspection. Without this patch cover failed to find source files which were in src_dirs, and threw the following exception: ERROR: eunit failed while processing /path/to/project: {'EXIT',{{badmatch,{error,no_source_code_found}}, [{rebar_eunit,'-cover_analyze/3-fun-0-',1, [{file,"src/rebar_eunit.erl"},{line,280}]}, {lists,foreach,2,[{file,"lists.erl"},{line,1262}]}, {rebar_eunit,cover_analyze,3, [{file,"src/rebar_eunit.erl"},{line,279}]}, {rebar_eunit,eunit,2,[{file,"src/rebar_eunit.erl"},{line,140}]}, {rebar_core,run_modules,4,[{file,"src/rebar_core.erl"},{line,425}]}, {rebar_core,execute,5,[{file,"src/rebar_core.erl"},{line,359}]}, {rebar_core,process_dir0,6,[{file,"src/rebar_core.erl"},{line,223}]}, {rebar_core,process_dir,4, [{file,"src/rebar_core.erl"},{line,130}]}]}} Now all source files are copied to .eunit.
Diffstat (limited to 'src')
-rw-r--r--src/rebar_eunit.erl13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
index 21228df..42c6fdd 100644
--- a/src/rebar_eunit.erl
+++ b/src/rebar_eunit.erl
@@ -84,8 +84,17 @@ eunit(Config, _AppFile) ->
%% Copy source files to eunit dir for cover in case they are not directly
%% in src but in a subdirectory of src. Cover only looks in cwd and ../src
- %% for source files.
- SrcErls = rebar_utils:find_files("src", ".*\\.erl\$"),
+ %% for source files. Also copy files from src_dirs.
+ ErlOpts = rebar_utils:erl_opts(Config),
+
+ SrcErls = lists:foldl(
+ fun(Dir, Acc) ->
+ lists:append(Acc, rebar_utils:find_files(Dir, ".*\\.erl\$"))
+ end,
+ [],
+ rebar_utils:src_dirs(proplists:append_values(src_dirs, ErlOpts))
+ ),
+ ?DEBUG("SrcErls: ~s\n", [SrcErls]),
%% If it is not the first time rebar eunit is executed, there will be source
%% files already present in ?EUNIT_DIR. Since some SCMs (like Perforce) set