123456789_123456789_123456789_123456789_123456789_

Class: Minitest::BacktraceFilter

Relationships & Source Files
Inherits: Object
Defined in: lib/minitest.rb

Overview

The standard backtrace filter for minitest.

See Minitest.backtrace_filter=.

Constant Summary

Class Method Summary

Instance Attribute Summary

  • #regexp rw

    The regular expression to use to filter backtraces.

Instance Method Summary

Constructor Details

.new(regexp = MT_RE) ⇒ BacktraceFilter

This method is for internal use only.
[ GitHub ]

  
# File 'lib/minitest.rb', line 1184

def initialize regexp = MT_RE # :nodoc:
  self.regexp = regexp
end

Instance Attribute Details

#regexp (rw)

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

[ GitHub ]

  
# File 'lib/minitest.rb', line 1182

attr_accessor :regexp

Instance Method Details

#filter(bt)

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

[ GitHub ]

  
# 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