Fix crash in oneshot coverage when file is missing or not valid Ruby#1158
Open
skryukov wants to merge 1 commit intosimplecov-ruby:mainfrom
Open
Fix crash in oneshot coverage when file is missing or not valid Ruby#1158skryukov wants to merge 1 commit intosimplecov-ruby:mainfrom
skryukov wants to merge 1 commit intosimplecov-ruby:mainfrom
Conversation
0b34b91 to
8ca1908
Compare
8ca1908 to
be8c7d9
Compare
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.
This PR fixes
Coverage.line_stubraisingErrno::ENOENTorSyntaxErrorduring oneshot coverage adaptation.Errno::ENOENT: In our case, gRPC proto stubs are auto-generated and gitignored. They exist when Ruby loads them (soCoveragetracks them), but may not exist on disk by the time SimpleCov'sat_exithook callsCoverage.line_stub. Since this happens duringat_exit, it's hard to orchestrate the process. User-configured filters (add_filter) could be applied earlier in the pipeline, butBlockFilterrequiresSourceFileobjects (which need the file on disk and parsed coverage data), so it can't work at the raw-path stage.SyntaxError: Also fixes the issue reported in #1154 comments whereCoverage.line_stubcrashes on non-Ruby files (e.g. YAML) tracked viaenable_coverage_for_eval.The fix: when
Coverage.line_stubfails, fall back to building the line array from the oneshot data alone. This preserves coverage results (with degraded nil/0 distinction for uncovered lines) instead of crashing.