|
42 | 42 | SimpleCov.start_tracking |
43 | 43 |
|
44 | 44 | 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 |
46 | 59 |
|
47 | 60 | RSpec.configure do |config| |
48 | 61 | config.after(:suite) do |
|
61 | 74 |
|
62 | 75 | SimpleCov::Formatter::HTMLFormatter.new(silent: true, output_dir: DOGFOOD_OUTPUT_DIR).format(result) |
63 | 76 |
|
64 | | - shortfalls = [] |
| 77 | + thresholds = DOGFOOD_THRESHOLDS[RUBY_ENGINE] || {} |
65 | 78 | stats = result.coverage_statistics |
66 | | - %i[line branch method].each do |criterion| |
| 79 | + shortfalls = thresholds.filter_map do |criterion, expected| |
67 | 80 | actual = stats[criterion]&.percent |
68 | | - next if actual.nil? || actual >= DOGFOOD_MINIMUM_COVERAGE |
| 81 | + next if actual.nil? || actual >= expected |
69 | 82 |
|
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) |
71 | 85 | end |
72 | 86 | next if shortfalls.empty? |
73 | 87 |
|
74 | 88 | $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", |
76 | 90 | shortfalls: shortfalls.join(", "), |
77 | | - expected: DOGFOOD_MINIMUM_COVERAGE, |
78 | 91 | dir: DOGFOOD_OUTPUT_DIR |
79 | 92 | ) |
80 | 93 | Kernel.exit(SimpleCov::ExitCodes::MINIMUM_COVERAGE) |
|
0 commit comments