Skip to content

Commit

Permalink
Don't modify relative ./ paths in BacktraceCleaner
Browse files Browse the repository at this point in the history
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 ./
  • Loading branch information
jhawthorn committed Oct 3, 2019
1 parent 804a4c1 commit dd5cbf5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 1 addition & 4 deletions railties/lib/rails/backtrace_cleaner.rb
Expand Up @@ -4,7 +4,7 @@

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
Expand All @@ -20,9 +20,6 @@ def initialize
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
Expand Down
9 changes: 9 additions & 0 deletions railties/test/backtrace_cleaner_test.rb
Expand Up @@ -17,6 +17,15 @@ def setup
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'",
Expand Down

0 comments on commit dd5cbf5

Please sign in to comment.