Skip to content
This repository
Browse code

eunit: analyze coverage only for cover compiled modules

This change fixes #310.
  • Loading branch information...
commit 22b703efa8d86c1fbd49273eda2c0252d93fd4fd 1 parent 7bd318c
Shunichi Shinohara authored September 13, 2012 tuncer committed September 13, 2012
4  src/rebar_eunit.erl
@@ -397,7 +397,9 @@ cover_analyze(_Config, [], _SrcModules) ->
397 397
     ok;
398 398
 cover_analyze(Config, FilteredModules, SrcModules) ->
399 399
     %% Generate coverage info for all the cover-compiled modules
400  
-    Coverage = lists:flatten([cover_analyze_mod(M) || M <- FilteredModules]),
  400
+    Coverage = lists:flatten([cover_analyze_mod(M)
  401
+                              || M <- FilteredModules,
  402
+                                 cover:is_compiled(M) =/= false]),
401 403
 
402 404
     %% Write index of coverage info
403 405
     cover_write_index(lists:sort(Coverage), SrcModules),
44  test/rebar_eunit_tests.erl
@@ -198,13 +198,18 @@ cover_test_() ->
198 198
      setup, fun() -> setup_cover_project(), rebar("-v eunit") end,
199 199
      fun teardown/1,
200 200
 
201  
-     [{"All cover reports are generated",
202  
-       assert_files_in("the temporary eunit directory",
203  
-                       expected_cover_generated_files())},
  201
+     fun(RebarOut) ->
  202
+             [{"Error messages are not present",
  203
+               ?_assert(string:str(RebarOut, "Cover analyze failed for") =:= 0)},
  204
+
  205
+              {"All cover reports are generated",
  206
+               assert_files_in("the temporary eunit directory",
  207
+                               expected_cover_generated_files())},
204 208
 
205  
-      {"Only production modules get coverage reports",
206  
-       assert_files_not_in("the temporary eunit directory",
207  
-                           [".eunit/myapp_mymod_tests.COVER.html"])}]}.
  209
+              {"Only production modules get coverage reports",
  210
+               assert_files_not_in("the temporary eunit directory",
  211
+                                   [".eunit/myapp_mymod_tests.COVER.html"])}]
  212
+     end}.
208 213
 
209 214
 cover_with_suite_test_() ->
210 215
     {"Ensure Cover runs with Tests in a test dir and a test suite",
@@ -215,17 +220,22 @@ cover_with_suite_test_() ->
215 220
      end,
216 221
      fun teardown/1,
217 222
 
218  
-     [{"Cover reports are generated for module",
219  
-       assert_files_in("the temporary eunit directory",
220  
-                       [".eunit/index.html",
221  
-                        ".eunit/mysuite.COVER.html"])},
222  
-
223  
-      {"Only production modules get coverage reports",
224  
-       assert_files_not_in("the temporary eunit directory",
225  
-                           [".eunit/myapp_app.COVER.html",
226  
-                            ".eunit/myapp_mymod.COVER.html",
227  
-                            ".eunit/myapp_sup.COVER.html",
228  
-                            ".eunit/myapp_mymod_tests.COVER.html"])}]}.
  223
+     fun(RebarOut) ->
  224
+             [{"Error messages are not present",
  225
+               ?_assert(string:str(RebarOut, "Cover analyze failed for") =:= 0)},
  226
+
  227
+              {"Cover reports are generated for module",
  228
+               assert_files_in("the temporary eunit directory",
  229
+                               [".eunit/index.html",
  230
+                                ".eunit/mysuite.COVER.html"])},
  231
+
  232
+              {"Only production modules get coverage reports",
  233
+               assert_files_not_in("the temporary eunit directory",
  234
+                                   [".eunit/myapp_app.COVER.html",
  235
+                                    ".eunit/myapp_mymod.COVER.html",
  236
+                                    ".eunit/myapp_sup.COVER.html",
  237
+                                    ".eunit/myapp_mymod_tests.COVER.html"])}]
  238
+     end}.
229 239
 
230 240
 expected_cover_generated_files() ->
231 241
     [".eunit/index.html",

0 notes on commit 22b703e

Please sign in to comment.
Something went wrong with that request. Please try again.