Skip to content

Dogfood#1181

Merged
sferik merged 10 commits into
mainfrom
dogfood
May 7, 2026
Merged

Dogfood#1181
sferik merged 10 commits into
mainfrom
dogfood

Conversation

@sferik
Copy link
Copy Markdown
Collaborator

@sferik sferik commented May 7, 2026

For #786.

This comment was marked as resolved.

sferik added 10 commits May 6, 2026 19:52
Min Ruby is 3.1+, so the upstream method is always available. The
SimpleCov-side flag was a duplicate that test mocks could flip out
from under the at_exit pipeline.
…eCov

Add filters: / groups: keyword arguments defaulting to SimpleCov.filters
/ SimpleCov.groups so existing call sites are unchanged. Tests can pass
filters: [] or an explicit list to opt out of the singleton entirely.

Also flip Metrics/ParameterLists CountKeywordArgs to false, which is
more honest than spot-disabling on the constructor.
Add output_dir: keyword (default nil → SimpleCov.coverage_path) so
formatter specs and the dogfood can write somewhere other than the
project's coverage/ directory. JSONFormatter's output message reflects
the explicit directory too. SimpleFormatter is pure-string and
MultiFormatter still instantiates wrapped formatters with no args.
start kept its public signature: it now just calls initial_setup then
start_tracking. The split lets dogfood test setups call start_tracking
directly (after starting Coverage early themselves) without inheriting
a fresh, empty configuration.
defaults.rb auto-registered the at_exit block on every require. Move
the registration into a new idempotent SimpleCov.install_at_exit_hook;
SimpleCov.start calls it, SimpleCov.start_tracking deliberately doesn't.
A no-op for normal users — the auto-hook returned early anyway when
start hadn't been called.
Bootstrap Coverage in spec/helper.rb before requiring simplecov, then
drive the formatter ourselves in an after(:suite) hook. Threshold
defaults to 100% and the build exits MINIMUM_COVERAGE when under;
SIMPLECOV_NO_DOGFOOD=1 skips the bootstrap.

Two follow-ups it surfaced: HTMLFormatter#format and JSONFormatter#format
now mkdir_p their output_dir, and simplecov_spec stubs Coverage.running?
to false in the start_coverage_measurement examples (Coverage is already
running under the dogfood bootstrap).
Backfill ~30 specs across simplecov, configuration, source_file,
file_list, filters, result_merger, multi_formatter, simulate_coverage,
and the three ExitCodes/*Check#report cases that lacked them.

Mark genuinely-unreachable paths with # simplecov:disable: parallel_tests
and JRuby branches, the .simplecov dotfile autoloader, ~/.simplecov,
the simplecov-profile-* gem fallback, the directive.rb encoding rescues,
the Configuration#formatters MultiFormatter-instance dead branch, and
SourceFile#parse_array_element's defensive ArgumentError. Also drop the
unused Directive#enabled? method.
Enable :branch in after(:suite) and threshold both line and branch at
100%. Add branch-targeting specs for the testable conditionals and bare
gates, SIMPLECOV_NO_DEFAULTS, the at_exit Proc.new fallback, status's
covered? else nil).

Also drop unnecessary &. operators in FileList and SourceFile where
the receiver is invariantly non-nil (line stats are always set;
SourceFile always assembles a full :line/:branch/:method
coverage_statistics hash). Those were producing dead 'else' branches.
Enable :method in after(:suite) and threshold all three criteria.

Two real fixes fell out: restore SourceFile#parse_ruby_array_string's
'try plain Ripper, then pre-quote on failure' approach (method-coverage
keys for simplecov-on-simplecov take the form
["#<Class:SimpleCov>", :name, ...] — valid Ruby with the wrapper
inside a quoted string), and merge singleton + instance method-coverage
keys in ResultAdapter#normalize_method_keys (Ruby's Coverage records
module_function methods twice; only one form is reachable, so the
other was always 0).
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.

Surfaced by https://github.com/simplecov-ruby/simplecov/actions/runs/25472411032
@sferik sferik merged commit 734a0a0 into main May 7, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants