Skip to content

Calling Simplecov.start more than once raises an exception #1003

Open
@dillonwelch

Description

@dillonwelch

It looks like ruby-head made an update a few days ago that caused Coverage.start to raise an exception if you call it more than once. Naturally, this will also cause SimpleCov.start to raise the same exception.

Here is an example of what happens:

Stopped processing SimpleCov as a previous error not related to SimpleCov has been detected
/home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/simplecov-0.21.2/lib/simplecov.rb:354:in `start': coverage measurement is already setup (RuntimeError)
	from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/simplecov-0.21.2/lib/simplecov.rb:354:in `start_coverage_with_criteria'
	from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/simplecov-0.21.2/lib/simplecov.rb:343:in `start_coverage_measurement'
	from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/simplecov-0.21.2/lib/simplecov.rb:59:in `start'
	from /home/runner/work/devise-security/devise-security/test/test_helper.rb:26:in `<top (required)>'
	from /home/runner/work/devise-security/devise-security/test/test_compatibility.rb:3:in `require'
	from /home/runner/work/devise-security/devise-security/test/test_compatibility.rb:3:in `<top (required)>'
	from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `require'
	from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:21:in `block in <main>'
	from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `select'
	from /home/runner/work/devise-security/devise-security/gemfiles/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb:6:in `<main>'

You can see at devise-security/devise-security#343 where the issue was fixed once I updated to only do this once.

Is there a way that SimpleCov can wrap this into something more presentable so that the fix is clear? It took me digging into the ruby source code to figure out why it only failed in Ruby 3.1 (aka ruby-head)

Also, the unstable tests on this repo appear to be failing? Doesn't seem related based on the error but I figure I'd point it out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions