Skip to content

Commit 8d4a104

Browse files
committed
Set per-engine dogfood thresholds
CRuby is the primary target and stays at 100% on line, branch, and method. JRuby and TruffleRuby `skip` specs that exercise branch/method coverage paths their Coverage module doesn't support, so the lib/ lines those specs would have hit stay uncovered there (~97.8% line on JRuby, 97.91% on TruffleRuby). Set their line thresholds at 97.5% — small buffer below today's actual, still catches meaningful regressions. Engines absent from DOGFOOD_THRESHOLDS get an informational HTML report only.
1 parent 20fac63 commit 8d4a104

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

spec/helper.rb

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,20 @@
4242
SimpleCov.start_tracking
4343

4444
DOGFOOD_OUTPUT_DIR = "tmp/dogfood"
45-
DOGFOOD_MINIMUM_COVERAGE = 100.0
45+
46+
# Per-engine thresholds. CRuby is the primary target and is held to
47+
# 100% on every criterion. JRuby and TruffleRuby `skip` specs that
48+
# exercise branch / method coverage paths their Coverage module
49+
# doesn't support, so the lib/ lines those specs would have hit stay
50+
# uncovered there — set the line threshold a hair below today's
51+
# actual to act as a regression guard rather than a strict ceiling.
52+
# Engines absent from this hash get an informational report only,
53+
# no threshold enforcement.
54+
DOGFOOD_THRESHOLDS = {
55+
"ruby" => {line: 100.0, branch: 100.0, method: 100.0},
56+
"jruby" => {line: 97.5},
57+
"truffleruby" => {line: 97.5}
58+
}.freeze
4659

4760
RSpec.configure do |config|
4861
config.after(:suite) do
@@ -61,20 +74,20 @@
6174

6275
SimpleCov::Formatter::HTMLFormatter.new(silent: true, output_dir: DOGFOOD_OUTPUT_DIR).format(result)
6376

64-
shortfalls = []
77+
thresholds = DOGFOOD_THRESHOLDS[RUBY_ENGINE] || {}
6578
stats = result.coverage_statistics
66-
%i[line branch method].each do |criterion|
79+
shortfalls = thresholds.filter_map do |criterion, expected|
6780
actual = stats[criterion]&.percent
68-
next if actual.nil? || actual >= DOGFOOD_MINIMUM_COVERAGE
81+
next if actual.nil? || actual >= expected
6982

70-
shortfalls << format("%<criterion>s coverage %<actual>.2f%%", criterion: criterion, actual: actual)
83+
format("%<criterion>s coverage %<actual>.2f%% (min %<expected>.2f%%)",
84+
criterion: criterion, actual: actual, expected: expected)
7185
end
7286
next if shortfalls.empty?
7387

7488
$stdout.puts format(
75-
"Dogfood %<shortfalls>s — below threshold %<expected>.2f%%. See %<dir>s/index.html",
89+
"Dogfood: %<shortfalls>s. See %<dir>s/index.html",
7690
shortfalls: shortfalls.join(", "),
77-
expected: DOGFOOD_MINIMUM_COVERAGE,
7891
dir: DOGFOOD_OUTPUT_DIR
7992
)
8093
Kernel.exit(SimpleCov::ExitCodes::MINIMUM_COVERAGE)

0 commit comments

Comments
 (0)