Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'digest'

digest = Digest::MD5.new
digest.update('test')
digest.update(ENV.fetch('BUNDLE_GEMFILE', 'gemfile')) if ENV['APPRAISAL_INITIALIZED']

ENV['ENABLE_COVERAGE'] ||= '1'

if ENV['ENABLE_COVERAGE'].to_i.positive?
SimpleCov.command_name(ENV['SIMPLECOV_COMMAND_NAME'] || digest.hexdigest)

# Hook Process._fork so forked children store their own coverage slice.
SimpleCov.merge_subprocesses true

SimpleCov.start do
merging true
add_filter %r{^/test/}
end
end
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ group :test do
gem 'rubocop-performance', '~> 1.26.0'
gem 'rubocop-rake', '~> 0.7.1'
gem 'rubocop-rspec', '~> 3.10.0'
gem 'simplecov', '~> 0.22.0'
gem 'simplecov', '~> 1.0.0'
gem 'yard', '~> 0.9.44'
if RUBY_VERSION >= '3.4'
gem 'base64'
Expand Down
8 changes: 1 addition & 7 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
SimpleCov.start

require 'rake'
require 'minitest'
require 'minitest/autorun'
Expand Down Expand Up @@ -44,7 +42,6 @@ def run_in_subprocess(env_vars = {}, opts = {})
read_pipe, write_pipe = IO.pipe

pid = fork do
SimpleCov.command_name "subprocess-#{Process.pid}"
read_pipe.close
env_vars.each { |key, value| ENV[key] = value }
ENV['OTEL_RUBY_REQUIRE_BUNDLER'] = 'false'
Expand Down Expand Up @@ -149,10 +146,7 @@ def run_in_subprocess(env_vars = {}, opts = {})
ensure
$stderr = old_stderr if defined?(old_stderr)
write_pipe.close

# Store the simplecov result for this process
SimpleCov::ResultMerger.store_result(SimpleCov::Result.new(Coverage.result)) if SimpleCov.running
exit!(0)
exit(0)
end
end

Expand Down