Permalink
Browse files

add a backtrace filter object

  • Loading branch information...
tenderlove committed Sep 23, 2012
1 parent e8b70f5 commit 1f85cb49285647fce5eb924495c75890d5d06fdc
Showing with 24 additions and 12 deletions.
  1. +24 −12 lib/minitest/unit.rb
View
@@ -30,24 +30,36 @@ class Assertion < Exception; end
class Skip < Assertion; end
- def self.filter_backtrace bt # :nodoc:
- return ["No backtrace"] unless bt
+ class << self
+ attr_accessor :backtrace_filter
+ end
+
+ class Filter # :nodoc:
+ def filter bt
+ return ["No backtrace"] unless bt
- new_bt = []
+ new_bt = []
+
+ unless $DEBUG then
+ bt.each do |line|
+ break if line =~ /lib\/minitest/
+ new_bt << line
+ end
- unless $DEBUG then
- bt.each do |line|
- break if line =~ /lib\/minitest/
- new_bt << line
+ new_bt = bt.reject { |line| line =~ /lib\/minitest/ } if new_bt.empty?
+ new_bt = bt.dup if new_bt.empty?
+ else
+ new_bt = bt.dup
end
- new_bt = bt.reject { |line| line =~ /lib\/minitest/ } if new_bt.empty?
- new_bt = bt.dup if new_bt.empty?
- else
- new_bt = bt.dup
+ new_bt
end
+ end
- new_bt
+ self.backtrace_filter = Filter.new
+
+ def self.filter_backtrace bt # :nodoc:
+ backtrace_filter.filter bt
end
##

0 comments on commit 1f85cb4

Please sign in to comment.