After oneshot_line coverage support was added in 522dc7d, minimum_coverage appears to crash with a KeyError when oneshot_line is used as the primary coverage.
It looks like minimum_coverage ends up checking :oneshot_line, while coverage_statistics only exposes :line, :branch, and :method.
Reproduction
Run this single-file repro script:
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "simplecov", github: "simplecov-ruby/simplecov", branch: "main"
end
require "tmpdir"
require "fileutils"
dir = Dir.mktmpdir("simplecov-oneshot-repro")
at_exit { FileUtils.remove_entry(dir) if Dir.exist?(dir) }
source_file = File.join(dir, "sample.rb")
File.write(source_file, <<~RUBY)
def greet(name)
return "hi" if name
"hello"
end
greet("world")
RUBY
require "simplecov"
SimpleCov.start do
enable_coverage :oneshot_line
primary_coverage :oneshot_line
minimum_coverage 100
end
load source_file
Expected behavior
minimum_coverage should work with oneshot_line coverage, or at least fail gracefully with a clear error.
Actual behavior
It raises:
'Hash#fetch': key not found: :oneshot_line (KeyError)
After
oneshot_linecoverage support was added in 522dc7d,minimum_coverageappears to crash with aKeyErrorwhenoneshot_lineis used as the primary coverage.It looks like
minimum_coverageends up checking:oneshot_line, whilecoverage_statisticsonly exposes:line,:branch, and:method.Reproduction
Run this single-file repro script:
Expected behavior
minimum_coverageshould work withoneshot_linecoverage, or at least fail gracefully with a clear error.Actual behavior
It raises: