forked from proper-testing/proper
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrebar.b6d3094.patch
183 lines (171 loc) · 8.02 KB
/
rebar.b6d3094.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
diff --git a/src/rebar_cover_utils.erl b/src/rebar_cover_utils.erl
index 7b85f1c..70849b2 100644
--- a/src/rebar_cover_utils.erl
+++ b/src/rebar_cover_utils.erl
@@ -106,10 +106,10 @@ init(Config, BeamFiles, TargetDir) ->
analyze(_Config, [], _SrcModules, _TargetDir) ->
ok;
-analyze(Config, FilteredModules, SrcModules, TargetDir) ->
+analyze(Config, _FilteredModules, SrcModules, TargetDir) ->
%% Generate coverage info for all the cover-compiled modules
Coverage = lists:flatten([analyze_mod(M)
- || M <- FilteredModules,
+ || M <- SrcModules,
cover:is_compiled(M) =/= false]),
%% Write index of coverage info
@@ -129,7 +129,9 @@ analyze(Config, FilteredModules, SrcModules, TargetDir) ->
%% Export coverage data, if configured
case rebar_config:get(Config, cover_export_enabled, false) of
true ->
- export_coverdata(TargetDir);
+ [export_coverdata(TargetDir, M) || M <- SrcModules,
+ cover:is_compiled(M) =/= false];
+ %% export_coverdata(TargetDir);
false ->
ok
end,
@@ -151,6 +153,7 @@ analyze(Config, FilteredModules, SrcModules, TargetDir) ->
end.
analyze_mod(Module) ->
+ io:format("Module: ~p~n", [Module]),
case cover:analyze(Module, coverage, module) of
{ok, {Module, {Covered, NotCovered}}} ->
%% Modules that include the eunit header get an implicit
@@ -274,9 +277,9 @@ json_file(TargetDir, Module) ->
cover_file(Module, TargetDir) ->
filename:join([TargetDir, atom_to_list(Module) ++ ".COVER.html"]).
-export_coverdata(TargetDir) ->
- ExportFile = filename:join(TargetDir, "cover.coverdata"),
- case cover:export(ExportFile) of
+export_coverdata(TargetDir, Module) ->
+ ExportFile = filename:join(TargetDir, atom_to_list(Module) ++ ".coverdata"),
+ case cover:export(ExportFile, Module) of
ok ->
?CONSOLE("Coverdata export: ~s~n", [ExportFile]);
{error, Reason} ->
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 412b29d..1eec6bd 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -528,7 +528,9 @@ expand_file_names(Files, Dirs) ->
list()) -> ok | {ok, any()} | {error, any(), any()}.
internal_erl_compile(Config, Source, OutDir, ErlOpts) ->
ok = filelib:ensure_dir(OutDir),
- Opts = [{outdir, OutDir}] ++ ErlOpts ++ [{i, "include"}, return],
+ Opts = [{outdir, OutDir}] ++
+ [Opt || Opt <- ErlOpts, Opt =/=eunit_nowarnings] ++
+ [{i, "include"}, [return || not lists:member(eunit_nowarnings, ErlOpts)]],
case compile:file(Source, Opts) of
{ok, _Mod} ->
ok;
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
index ebf76bc..2fcc28d 100644
--- a/src/rebar_eunit.erl
+++ b/src/rebar_eunit.erl
@@ -87,7 +87,8 @@ eunit(Config, _AppFile) ->
%% Save code path
CodePath = setup_code_path(),
CompileOnly = rebar_config:get_global(Config, compile_only, false),
- {ok, SrcErls} = rebar_erlc_compiler:test_compile(Config, "eunit",
+ NoWarningConfig = rebar_config:set(Config, erl_opts, [eunit_nowarnings]),
+ {ok, SrcErls} = rebar_erlc_compiler:test_compile(NoWarningConfig, "eunit",
?EUNIT_DIR),
case CompileOnly of
"true" ->
@@ -171,7 +172,12 @@ run_eunit(Config, CodePath, SrcErls) ->
StatusBefore = status_before_eunit(),
EunitResult = perform_eunit(Config, Tests),
- rebar_cover_utils:perform_cover(Config, FilteredModules, SrcModules,
+ BlackListedModules = rebar_config:get(Config, cover_skip_modules, []),
+ {CoverModules, CoverSrc} =
+ {[Mod || Mod <- FilteredModules, not lists:member(Mod, BlackListedModules)],
+ [Src || Src <- SrcModules, not lists:member(Src, BlackListedModules)]},
+
+ rebar_cover_utils:perform_cover(Config, CoverModules, CoverSrc,
eunit_dir()),
rebar_cover_utils:close(CoverLog),
diff --git a/src/rebar_cover_utils.erl b/src/rebar_cover_utils.erl
index 7b85f1c..70849b2 100644
--- a/src/rebar_cover_utils.erl
+++ b/src/rebar_cover_utils.erl
@@ -106,10 +106,10 @@ init(Config, BeamFiles, TargetDir) ->
analyze(_Config, [], _SrcModules, _TargetDir) ->
ok;
-analyze(Config, FilteredModules, SrcModules, TargetDir) ->
+analyze(Config, _FilteredModules, SrcModules, TargetDir) ->
%% Generate coverage info for all the cover-compiled modules
Coverage = lists:flatten([analyze_mod(M)
- || M <- FilteredModules,
+ || M <- SrcModules,
cover:is_compiled(M) =/= false]),
%% Write index of coverage info
@@ -129,7 +129,9 @@ analyze(Config, FilteredModules, SrcModules, TargetDir) ->
%% Export coverage data, if configured
case rebar_config:get(Config, cover_export_enabled, false) of
true ->
- export_coverdata(TargetDir);
+ [export_coverdata(TargetDir, M) || M <- SrcModules,
+ cover:is_compiled(M) =/= false];
+ %% export_coverdata(TargetDir);
false ->
ok
end,
@@ -151,6 +153,7 @@ analyze(Config, FilteredModules, SrcModules, TargetDir) ->
end.
analyze_mod(Module) ->
+ io:format("Module: ~p~n", [Module]),
case cover:analyze(Module, coverage, module) of
{ok, {Module, {Covered, NotCovered}}} ->
%% Modules that include the eunit header get an implicit
@@ -274,9 +277,9 @@ json_file(TargetDir, Module) ->
cover_file(Module, TargetDir) ->
filename:join([TargetDir, atom_to_list(Module) ++ ".COVER.html"]).
-export_coverdata(TargetDir) ->
- ExportFile = filename:join(TargetDir, "cover.coverdata"),
- case cover:export(ExportFile) of
+export_coverdata(TargetDir, Module) ->
+ ExportFile = filename:join(TargetDir, atom_to_list(Module) ++ ".coverdata"),
+ case cover:export(ExportFile, Module) of
ok ->
?CONSOLE("Coverdata export: ~s~n", [ExportFile]);
{error, Reason} ->
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 412b29d..ebbe40e 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -528,7 +528,9 @@ expand_file_names(Files, Dirs) ->
list()) -> ok | {ok, any()} | {error, any(), any()}.
internal_erl_compile(Config, Source, OutDir, ErlOpts) ->
ok = filelib:ensure_dir(OutDir),
- Opts = [{outdir, OutDir}] ++ ErlOpts ++ [{i, "include"}, return],
+ Opts = [{outdir, OutDir}] ++
+ [Opt || Opt <- ErlOpts, Opt =/= eunit_nowarnings] ++
+ [{i, "include"} | [return || not lists:member(eunit_nowarnings, ErlOpts)]],
case compile:file(Source, Opts) of
{ok, _Mod} ->
ok;
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
index ebf76bc..74a49d1 100644
--- a/src/rebar_eunit.erl
+++ b/src/rebar_eunit.erl
@@ -87,7 +87,8 @@ eunit(Config, _AppFile) ->
%% Save code path
CodePath = setup_code_path(),
CompileOnly = rebar_config:get_global(Config, compile_only, false),
- {ok, SrcErls} = rebar_erlc_compiler:test_compile(Config, "eunit",
+ NoWarningConfig = rebar_config:set(Config, erl_opts, [eunit_nowarnings]),
+ {ok, SrcErls} = rebar_erlc_compiler:test_compile(NoWarningConfig, "eunit",
?EUNIT_DIR),
case CompileOnly of
"true" ->
@@ -171,7 +172,11 @@ run_eunit(Config, CodePath, SrcErls) ->
StatusBefore = status_before_eunit(),
EunitResult = perform_eunit(Config, Tests),
- rebar_cover_utils:perform_cover(Config, FilteredModules, SrcModules,
+ BlackListedModules = rebar_config:get(Config, cover_skip_modules, []),
+ CoverModules = [Mod || Mod <- FilteredModules, not lists:member(Mod, BlackListedModules)],
+ CoverSrc = [Src || Src <- SrcModules, not lists:member(Src, BlackListedModules)],
+
+ rebar_cover_utils:perform_cover(Config, CoverModules, CoverSrc,
eunit_dir()),
rebar_cover_utils:close(CoverLog),