class Minitest::BacktraceFilter

The standard backtrace filter for minitest.

See Minitest.backtrace_filter=.

Attributes

regexp[RW]

Public Class Methods

new(regexp = MT_RE) click to toggle source
# File minitest-5.22.3/lib/minitest.rb, line 1114
def initialize regexp = MT_RE
  self.regexp = regexp
end

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.22.3/lib/minitest.rb, line 1122
def filter bt
  return ["No backtrace"] unless bt

  return bt.dup if $DEBUG || ENV["MT_DEBUG"]

  new_bt = bt.take_while { |line| line.to_s !~ regexp }
  new_bt = bt.select     { |line| line.to_s !~ regexp } if new_bt.empty?
  new_bt = bt.dup                                       if new_bt.empty?

  new_bt
end