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
bt
to something useful. -
#initialize(regexp = MT_RE) ⇒ BacktraceFilter
constructor
:nodoc:.
Constructor Details
#initialize(regexp = MT_RE) ⇒ BacktraceFilter
:nodoc:
1184 1185 1186 |
# File 'lib/minitest.rb', line 1184 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
.
1182 1183 1184 |
# File 'lib/minitest.rb', line 1182 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).
1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 |
# File 'lib/minitest.rb', line 1192 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 |