Allow Gem paths to be stripped from file names in stacktraces when they contain a Regexp special character #764
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.
Goal
We strip the Gem paths from file names in stack traces, but this doesn't work if there's a regexp special character
For example, the Ruby 3.2 RC contains a '+' in the gem path (at least locally and on CI):
/.../.gem/ruby/3.2.0+3
This won't match any paths when used in a Regexp, because it is expecting one or more
0
characters, rather than the literal characters0+
. I've changed this matching logic to use a string instead of a Regexp to sidestep this problem and save having to escape the pathI spent a bit of time looking at adding unit tests for this but decided not to in the end because it involves reaching into
Gem
internals and, with the wide range of Ruby versions we support, that didn't seem like a good idea. We already have tests for this stripping that use the real Gem path to prove this doesn't break anythingTesting
This caused a test to fail on the Ruby 3.2 RC, which now passes with this change