Class: Minitest::BacktraceFilter
Overview
The standard backtrace filter for minitest.
See Minitest.backtrace_filter=.
Constant Summary collapse
- MT_RE =
:nodoc:
%r%lib/minitest|internal:warning%
Instance Attribute Summary collapse
-
#regexp ⇒ Object
The regular expression to use to filter backtraces.
Instance Method Summary collapse
-
#filter(bt) ⇒ Object
Filter
btto something useful. -
#initialize(regexp = MT_RE) ⇒ BacktraceFilter
constructor
:nodoc:.
Constructor Details
#initialize(regexp = MT_RE) ⇒ BacktraceFilter
:nodoc:
1200 1201 1202 |
# File 'lib/minitest.rb', line 1200 def initialize regexp = MT_RE # :nodoc: self.regexp = regexp end |
Instance Attribute Details
#regexp ⇒ Object
The regular expression to use to filter backtraces. Defaults to MT_RE.
1198 1199 1200 |
# File 'lib/minitest.rb', line 1198 def regexp @regexp end |
Instance Method Details
#filter(bt) ⇒ Object
Filter bt to something useful. Returns the whole thing if $DEBUG (ruby) or $MT_DEBUG (env).
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 |
# File 'lib/minitest.rb', line 1208 def filter bt return ["No backtrace"] unless bt return bt.dup if $DEBUG || ENV["MT_DEBUG"] new_bt = bt.take_while { |line| !regexp.match? line.to_s } new_bt = bt.select { |line| !regexp.match? line.to_s } if new_bt.empty? new_bt = bt.dup if new_bt.empty? new_bt end |