summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShunichi Shinohara <shino.shun@gmail.com>2012-09-13 00:05:59 +0900
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2012-09-13 22:30:30 +0200
commit22b703efa8d86c1fbd49273eda2c0252d93fd4fd (patch)
tree233a445548f03cb53c2a52a5d87732ffddc94152
parent7bd318c219bc283d5df16a0401aae00546fc8eea (diff)
eunit: analyze coverage only for cover compiled modules
This change fixes #310.
-rw-r--r--src/rebar_eunit.erl4
-rw-r--r--test/rebar_eunit_tests.erl44
2 files changed, 30 insertions, 18 deletions
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
index 02d2bf3..b82da0f 100644
--- a/src/rebar_eunit.erl
+++ b/src/rebar_eunit.erl
@@ -397,7 +397,9 @@ cover_analyze(_Config, [], _SrcModules) ->
ok;
cover_analyze(Config, FilteredModules, SrcModules) ->
%% 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
cover_write_index(lists:sort(Coverage), SrcModules),
diff --git a/test/rebar_eunit_tests.erl b/test/rebar_eunit_tests.erl
index fb01a49..7b2eec5 100644
--- a/test/rebar_eunit_tests.erl
+++ b/test/rebar_eunit_tests.erl
@@ -198,13 +198,18 @@ cover_test_() ->
setup, fun() -> setup_cover_project(), rebar("-v eunit") end,
fun teardown/1,
- [{"All cover reports are generated",
- assert_files_in("the temporary eunit directory",
- expected_cover_generated_files())},
+ fun(RebarOut) ->
+ [{"Error messages are not present",
+ ?_assert(string:str(RebarOut, "Cover analyze failed for") =:= 0)},
+
+ {"All cover reports are generated",
+ assert_files_in("the temporary eunit directory",
+ expected_cover_generated_files())},
- {"Only production modules get coverage reports",
- assert_files_not_in("the temporary eunit directory",
- [".eunit/myapp_mymod_tests.COVER.html"])}]}.
+ {"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_() ->
{"Ensure Cover runs with Tests in a test dir and a test suite",
@@ -215,17 +220,22 @@ cover_with_suite_test_() ->
end,
fun teardown/1,
- [{"Cover reports are generated for module",
- assert_files_in("the temporary eunit directory",
- [".eunit/index.html",
- ".eunit/mysuite.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"])}]}.
+ fun(RebarOut) ->
+ [{"Error messages are not present",
+ ?_assert(string:str(RebarOut, "Cover analyze failed for") =:= 0)},
+
+ {"Cover reports are generated for module",
+ assert_files_in("the temporary eunit directory",
+ [".eunit/index.html",
+ ".eunit/mysuite.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() ->
[".eunit/index.html",