Browse files

Fix that tests run in forked processes were printing coverage reports

For a few tests, we shell out to `ruby -e "require 'fakeweb'; ..."` to get a
clean environment in order to check what warnings appear when you combine
FakeWeb with other libs. Recently these processes starting printing coverage
reports, which messes with our assertions about the warnings output.

This sets the SimpleCov formatter to `MultiFormatter[]` for those processes,
which keeps them collecting/logging coverage data while suppressing any output.

p.s. this also sneaks in a more robust technique for checking whether the full
suite is being run (in #running_all_tests?).
  • Loading branch information...
1 parent 6f712bf commit 870f37323002c4773754fd5a15cfa60a121f51fc @chrisk committed Nov 18, 2013
Showing with 11 additions and 6 deletions.
  1. +11 −6 test/helpers/start_simplecov.rb
17 test/helpers/start_simplecov.rb
@@ -10,23 +10,28 @@ def start_simplecov
SimpleCov.start do
add_filter "/test/"
- minimum_coverage 100 if running_all_tests?
+ minimum_coverage 100 if this_process_responsible_for_coverage_reporting?
command_name SIMPLECOV_COMMAND_NAME if child_test_process?
formatter simplecov_formatter_class
def simplecov_formatter_class
include SimpleCov::Formatter
- if html_report_requested?
- MultiFormatter[HTMLFormatter, Console]
- else
- Console
+ formatters = []
+ if this_process_responsible_for_coverage_reporting?
+ formatters << Console
+ formatters << HTMLFormatter if html_report_requested?
+ MultiFormatter[*formatters]
+ end
+ def this_process_responsible_for_coverage_reporting?
+ running_all_tests? && !child_test_process?
def running_all_tests?
- ENV['TEST'].nil?
+ ARGV == Dir["test/test_*.rb"] - ["test/test_helper.rb"]
def child_test_process?

0 comments on commit 870f373

Please sign in to comment.