Skip to content

Commit

Permalink
add a backtrace filter object
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Sep 23, 2012
1 parent e8b70f5 commit 1f85cb4
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions lib/minitest/unit.rb
Expand Up @@ -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

##
Expand Down

0 comments on commit 1f85cb4

Please sign in to comment.