|
30 | 30 | SimpleCov.start_tracking |
31 | 31 |
|
32 | 32 | 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 |
34 | 47 |
|
35 | 48 | RSpec.configure do |config| |
36 | 49 | config.after(:suite) do |
|
49 | 62 |
|
50 | 63 | SimpleCov::Formatter::HTMLFormatter.new(silent: true, output_dir: DOGFOOD_OUTPUT_DIR).format(result) |
51 | 64 |
|
52 | | - shortfalls = [] |
| 65 | + thresholds = DOGFOOD_THRESHOLDS[RUBY_ENGINE] || {} |
53 | 66 | stats = result.coverage_statistics |
54 | | - %i[line branch method].each do |criterion| |
| 67 | + shortfalls = thresholds.filter_map do |criterion, expected| |
55 | 68 | actual = stats[criterion]&.percent |
56 | | - next if actual.nil? || actual >= DOGFOOD_MINIMUM_COVERAGE |
| 69 | + next if actual.nil? || actual >= expected |
57 | 70 |
|
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) |
59 | 73 | end |
60 | 74 | next if shortfalls.empty? |
61 | 75 |
|
62 | 76 | $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", |
64 | 78 | shortfalls: shortfalls.join(", "), |
65 | | - expected: DOGFOOD_MINIMUM_COVERAGE, |
66 | 79 | dir: DOGFOOD_OUTPUT_DIR |
67 | 80 | ) |
68 | 81 | Kernel.exit(SimpleCov::ExitCodes::MINIMUM_COVERAGE) |
|
0 commit comments