mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't modify relative ./ paths in BacktraceCleaner
Previously a path starting with ./ would be replaced to start with /. IMO this didn't particularly make sense since / reads as though it's from the root of the filesystem. This commit removes that filter, preserves ./, and updates the silencer not to remove lines starting with ./
This commit is contained in:
parent
804a4c144e
commit
dd5cbf58ed
2 changed files with 10 additions and 4 deletions
|
@ -4,7 +4,7 @@ require "active_support/backtrace_cleaner"
|
|||
|
||||
module Rails
|
||||
class BacktraceCleaner < ActiveSupport::BacktraceCleaner
|
||||
APP_DIRS_PATTERN = /\A\/?(?:app|config|lib|test|\(\w*\))/
|
||||
APP_DIRS_PATTERN = /\A(?:\.\/)?(?:app|config|lib|test|\(\w*\))/
|
||||
RENDER_TEMPLATE_PATTERN = /:in `.*_\w+_{2,3}\d+_\d+'/
|
||||
|
||||
def initialize
|
||||
|
@ -20,9 +20,6 @@ module Rails
|
|||
line
|
||||
end
|
||||
end
|
||||
add_filter do |line|
|
||||
line.start_with?("./") ? line.from(1) : line
|
||||
end
|
||||
add_silencer { |line| !APP_DIRS_PATTERN.match?(line) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,15 @@ class BacktraceCleanerTest < ActiveSupport::TestCase
|
|||
assert_equal 1, result.length
|
||||
end
|
||||
|
||||
test "should show relative paths" do
|
||||
backtrace = [ "./test/backtrace_cleaner_test.rb:123",
|
||||
"/Path/to/rails/activesupport/some_testing_file.rb:42:in `test'",
|
||||
"bin/rails:4:in `<main>'" ]
|
||||
result = @cleaner.clean(backtrace)
|
||||
assert_equal "./test/backtrace_cleaner_test.rb:123", result[0]
|
||||
assert_equal 1, result.length
|
||||
end
|
||||
|
||||
test "can filter for noise" do
|
||||
backtrace = [ "(irb):1",
|
||||
"/Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'",
|
||||
|
|
Loading…
Reference in a new issue