class Minitest::BacktraceFilter

The standard backtrace filter for minitest.

See Minitest.backtrace_filter=.

Attributes

regexp[RW]

The regular expression to use to filter backtraces. Defaults to MT_RE.

Public Instance Methods

filter(bt) click to toggle source

Filter bt to something useful. Returns the whole thing if $DEBUG (ruby) or $MT_DEBUG (env).

# File minitest-5.25.1/lib/minitest.rb, line 1191
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