2008-11-22 12:06:08 -05:00
|
|
|
require 'abstract_unit'
|
|
|
|
|
|
|
|
class BacktraceCleanerFilterTest < ActiveSupport::TestCase
|
|
|
|
def setup
|
|
|
|
@bc = ActiveSupport::BacktraceCleaner.new
|
|
|
|
@bc.add_filter { |line| line.gsub("/my/prefix", '') }
|
|
|
|
end
|
2010-08-14 01:13:00 -04:00
|
|
|
|
2012-06-18 21:23:28 -04:00
|
|
|
test "backtrace should filter all lines in a backtrace, removing prefixes" do
|
|
|
|
assert_equal \
|
|
|
|
["/my/class.rb", "/my/module.rb"],
|
|
|
|
@bc.clean(["/my/prefix/my/class.rb", "/my/prefix/my/module.rb"])
|
2008-11-22 12:06:08 -05:00
|
|
|
end
|
2010-03-27 12:47:39 -04:00
|
|
|
|
|
|
|
test "backtrace cleaner should allow removing filters" do
|
|
|
|
@bc.remove_filters!
|
|
|
|
assert_equal "/my/prefix/my/class.rb", @bc.clean(["/my/prefix/my/class.rb"]).first
|
|
|
|
end
|
2010-08-14 01:13:00 -04:00
|
|
|
|
2008-11-22 12:06:08 -05:00
|
|
|
test "backtrace should contain unaltered lines if they dont match a filter" do
|
|
|
|
assert_equal "/my/other_prefix/my/class.rb", @bc.clean([ "/my/other_prefix/my/class.rb" ]).first
|
|
|
|
end
|
2010-08-14 01:13:00 -04:00
|
|
|
|
2008-11-22 12:06:08 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
class BacktraceCleanerSilencerTest < ActiveSupport::TestCase
|
|
|
|
def setup
|
|
|
|
@bc = ActiveSupport::BacktraceCleaner.new
|
|
|
|
@bc.add_silencer { |line| line =~ /mongrel/ }
|
|
|
|
end
|
2010-08-14 01:13:00 -04:00
|
|
|
|
2008-11-22 12:06:08 -05:00
|
|
|
test "backtrace should not contain lines that match the silencer" do
|
|
|
|
assert_equal \
|
2010-08-14 01:13:00 -04:00
|
|
|
[ "/other/class.rb" ],
|
2008-11-22 12:06:08 -05:00
|
|
|
@bc.clean([ "/mongrel/class.rb", "/other/class.rb", "/mongrel/stuff.rb" ])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class BacktraceCleanerFilterAndSilencerTest < ActiveSupport::TestCase
|
|
|
|
def setup
|
|
|
|
@bc = ActiveSupport::BacktraceCleaner.new
|
|
|
|
@bc.add_filter { |line| line.gsub("/mongrel", "") }
|
|
|
|
@bc.add_silencer { |line| line =~ /mongrel/ }
|
|
|
|
end
|
2010-08-14 01:13:00 -04:00
|
|
|
|
2008-11-22 12:06:08 -05:00
|
|
|
test "backtrace should not silence lines that has first had their silence hook filtered out" do
|
|
|
|
assert_equal [ "/class.rb" ], @bc.clean([ "/mongrel/class.rb" ])
|
|
|
|
end
|
2010-03-27 12:47:39 -04:00
|
|
|
end
|