mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
eunit: analyze coverage only for cover compiled modules
This change fixes #310.
This commit is contained in:
parent
7bd318c219
commit
22b703efa8
2 changed files with 29 additions and 17 deletions
|
@ -397,7 +397,9 @@ cover_analyze(_Config, [], _SrcModules) ->
|
||||||
ok;
|
ok;
|
||||||
cover_analyze(Config, FilteredModules, SrcModules) ->
|
cover_analyze(Config, FilteredModules, SrcModules) ->
|
||||||
%% Generate coverage info for all the cover-compiled modules
|
%% Generate coverage info for all the cover-compiled modules
|
||||||
Coverage = lists:flatten([cover_analyze_mod(M) || M <- FilteredModules]),
|
Coverage = lists:flatten([cover_analyze_mod(M)
|
||||||
|
|| M <- FilteredModules,
|
||||||
|
cover:is_compiled(M) =/= false]),
|
||||||
|
|
||||||
%% Write index of coverage info
|
%% Write index of coverage info
|
||||||
cover_write_index(lists:sort(Coverage), SrcModules),
|
cover_write_index(lists:sort(Coverage), SrcModules),
|
||||||
|
|
|
@ -198,13 +198,18 @@ cover_test_() ->
|
||||||
setup, fun() -> setup_cover_project(), rebar("-v eunit") end,
|
setup, fun() -> setup_cover_project(), rebar("-v eunit") end,
|
||||||
fun teardown/1,
|
fun teardown/1,
|
||||||
|
|
||||||
[{"All cover reports are generated",
|
fun(RebarOut) ->
|
||||||
assert_files_in("the temporary eunit directory",
|
[{"Error messages are not present",
|
||||||
expected_cover_generated_files())},
|
?_assert(string:str(RebarOut, "Cover analyze failed for") =:= 0)},
|
||||||
|
|
||||||
{"Only production modules get coverage reports",
|
{"All cover reports are generated",
|
||||||
assert_files_not_in("the temporary eunit directory",
|
assert_files_in("the temporary eunit directory",
|
||||||
[".eunit/myapp_mymod_tests.COVER.html"])}]}.
|
expected_cover_generated_files())},
|
||||||
|
|
||||||
|
{"Only production modules get coverage reports",
|
||||||
|
assert_files_not_in("the temporary eunit directory",
|
||||||
|
[".eunit/myapp_mymod_tests.COVER.html"])}]
|
||||||
|
end}.
|
||||||
|
|
||||||
cover_with_suite_test_() ->
|
cover_with_suite_test_() ->
|
||||||
{"Ensure Cover runs with Tests in a test dir and a test suite",
|
{"Ensure Cover runs with Tests in a test dir and a test suite",
|
||||||
|
@ -215,17 +220,22 @@ cover_with_suite_test_() ->
|
||||||
end,
|
end,
|
||||||
fun teardown/1,
|
fun teardown/1,
|
||||||
|
|
||||||
[{"Cover reports are generated for module",
|
fun(RebarOut) ->
|
||||||
assert_files_in("the temporary eunit directory",
|
[{"Error messages are not present",
|
||||||
[".eunit/index.html",
|
?_assert(string:str(RebarOut, "Cover analyze failed for") =:= 0)},
|
||||||
".eunit/mysuite.COVER.html"])},
|
|
||||||
|
|
||||||
{"Only production modules get coverage reports",
|
{"Cover reports are generated for module",
|
||||||
assert_files_not_in("the temporary eunit directory",
|
assert_files_in("the temporary eunit directory",
|
||||||
[".eunit/myapp_app.COVER.html",
|
[".eunit/index.html",
|
||||||
".eunit/myapp_mymod.COVER.html",
|
".eunit/mysuite.COVER.html"])},
|
||||||
".eunit/myapp_sup.COVER.html",
|
|
||||||
".eunit/myapp_mymod_tests.COVER.html"])}]}.
|
{"Only production modules get coverage reports",
|
||||||
|
assert_files_not_in("the temporary eunit directory",
|
||||||
|
[".eunit/myapp_app.COVER.html",
|
||||||
|
".eunit/myapp_mymod.COVER.html",
|
||||||
|
".eunit/myapp_sup.COVER.html",
|
||||||
|
".eunit/myapp_mymod_tests.COVER.html"])}]
|
||||||
|
end}.
|
||||||
|
|
||||||
expected_cover_generated_files() ->
|
expected_cover_generated_files() ->
|
||||||
[".eunit/index.html",
|
[".eunit/index.html",
|
||||||
|
|
Loading…
Reference in a new issue