Skip to content

Commit fa35dcd

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 report only.
1 parent 7ba7bc9 commit fa35dcd

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
@@ -30,7 +30,20 @@
3030
SimpleCov.start_tracking
3131

3232
DOGFOOD_OUTPUT_DIR = "tmp/dogfood"
33-
DOGFOOD_MINIMUM_COVERAGE = 100.0
33+
34+
# Per-engine thresholds. CRuby is the primary target and is held to
35+
# 100% on every criterion. JRuby and TruffleRuby `skip` specs that
36+
# exercise branch / method coverage paths their Coverage module
37+
# doesn't support, so the lib/ lines those specs would have hit stay
38+
# uncovered there — set the line threshold a hair below today's
39+
# actual to act as a regression guard rather than a strict ceiling.
40+
# Engines absent from this hash get an informational report only,
41+
# no threshold enforcement.
42+
DOGFOOD_THRESHOLDS = {
43+
"ruby" => {line: 100.0, branch: 100.0, method: 100.0},
44+
"jruby" => {line: 97.5},
45+
"truffleruby" => {line: 97.5}
46+
}.freeze
3447

3548
RSpec.configure do |config|
3649
config.after(:suite) do
@@ -49,20 +62,20 @@
4962

5063
SimpleCov::Formatter::HTMLFormatter.new(silent: true, output_dir: DOGFOOD_OUTPUT_DIR).format(result)
5164

52-
shortfalls = []
65+
thresholds = DOGFOOD_THRESHOLDS[RUBY_ENGINE] || {}
5366
stats = result.coverage_statistics
54-
%i[line branch method].each do |criterion|
67+
shortfalls = thresholds.filter_map do |criterion, expected|
5568
actual = stats[criterion]&.percent
56-
next if actual.nil? || actual >= DOGFOOD_MINIMUM_COVERAGE
69+
next if actual.nil? || actual >= expected
5770

58-
shortfalls << format("%<criterion>s coverage %<actual>.2f%%", criterion: criterion, actual: actual)
71+
format("%<criterion>s coverage %<actual>.2f%% (min %<expected>.2f%%)",
72+
criterion: criterion, actual: actual, expected: expected)
5973
end
6074
next if shortfalls.empty?
6175

6276
$stdout.puts format(
63-
"Dogfood %<shortfalls>s — below threshold %<expected>.2f%%. See %<dir>s/index.html",
77+
"Dogfood: %<shortfalls>s. See %<dir>s/index.html",
6478
shortfalls: shortfalls.join(", "),
65-
expected: DOGFOOD_MINIMUM_COVERAGE,
6679
dir: DOGFOOD_OUTPUT_DIR
6780
)
6881
Kernel.exit(SimpleCov::ExitCodes::MINIMUM_COVERAGE)

0 commit comments

Comments
 (0)