Improve constant mapping with ancestor expansion (default on)#7
Open
Improve constant mapping with ancestor expansion (default on)#7
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves constant-reference mapping for shared concerns/mixins and enables the behavior by default.
Changes:
:const_ancestor_files).ancestor_referencesdefault fromfalsetotrue.Problem
We observed mapping gaps where a changed module/concern did not map to all consuming controller specs in CI. In eagerload/boot-heavy environments, a file can be loaded once and then reused, so line execution and simple file-load signals are insufficient to connect all impacted tests.
Solution
When
constant_referencesis enabled, FastCov already resolves referenced constants to defining files. This PR adds optional ancestor expansion: if a resolved constant is a class/module, FastCov also resolves its ancestors (includes/extends/superclasses) and adds those source files to impacted output.With this change, updates to shared mixins/concerns are much more likely to map to tests that reference consumers, even when the concern file itself is not re-executed during that worker's run.
Default Behavior
ancestor_referencesnow defaults totrue.You can disable it explicitly:
Benchmark (vs existing baseline)
From
bin/benchmark:0.398 ms(+1.7%)0.006 ms(+20.5%)0.130 ms0.003 msValidation
bundle exec rspec --fail-fastbin/benchmark --baseline(run before implementation)bin/benchmark(post-change compare)