summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/json/test_helper.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/test/json/test_helper.rb b/test/json/test_helper.rb
index a788804dde..24d98170bb 100644
--- a/test/json/test_helper.rb
+++ b/test/json/test_helper.rb
@@ -1,14 +1,29 @@
$LOAD_PATH.unshift(File.expand_path('../../../ext', __FILE__), File.expand_path('../../../lib', __FILE__))
require 'coverage'
-Coverage.start
+
+branches_supported = Coverage.respond_to?(:supported?) && Coverage.supported?(:branches)
+
+# Coverage module must be started before SimpleCov to work around the cyclic require order.
+# Track both branches and lines, or else SimpleCov misleadingly reports 0/0 = 100% for non-branching files.
+Coverage.start(lines: true,
+ branches: branches_supported)
begin
require 'simplecov'
rescue LoadError
# Don't fail Ruby's test suite
else
- SimpleCov.start
+ SimpleCov.start do
+ # Enabling both coverage types to let SimpleCov know to output them together in reports
+ enable_coverage :line
+ enable_coverage :branch if branches_supported
+
+ # Can't always trust SimpleCov to find files implicitly
+ track_files 'lib/**/*.rb'
+
+ add_filter 'lib/json/truffle_ruby' unless RUBY_ENGINE == 'truffleruby'
+ end
end
require 'json'