提交 5611f4b4 编写于 作者: J Jonathan Hefner

Anchor BacktraceCleaner gem filter regexp

This ensures the default gem filter does not affect backtrace lines that
have a subpath incidentally matching a gem path.

Fixes #40196.
上级 580eefe1
......@@ -91,7 +91,7 @@ def add_gem_filter
gems_paths = (Gem.path | [Gem.default_dir]).map { |p| Regexp.escape(p) }
return if gems_paths.empty?
gems_regexp = %r{(#{gems_paths.join('|')})/(bundler/)?gems/([^/]+)-([\w.]+)/(.*)}
gems_regexp = %r{\A(#{gems_paths.join('|')})/(bundler/)?gems/([^/]+)-([\w.]+)/(.*)}
gems_result = '\3 (\4) \5'
add_filter { |line| line.sub(gems_regexp, gems_result) }
end
......
......@@ -124,4 +124,10 @@ def setup
result = @bc.clean(backtrace)
assert_equal %w[other/file.rb], result
end
test "should preserve lines that have a subpath matching a gem path" do
backtrace = [Gem.default_dir, *Gem.path].map { |path| "/parent#{path}/gems/nosuchgem-1.2.3/lib/foo.rb" }
assert_equal backtrace, @bc.clean(backtrace)
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册