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 characters 0+. I've changed this matching logic to use a string instead of a Regexp to sidestep this problem and save having to escape the path
I 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 anything
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