Sha256: a608a325f096569d86696c7d334afbd466cd2e8ee203b5f457544fcd092d9c81

Contents?: true

Size: 904 Bytes

Versions: 1

Compression:

Stored size: 904 Bytes

Contents

module Micron

  # Default backtrace filter
  #
  # This can be swapped out by setting Micron::Runner.backtrace_filter
  # to a block, proc, lambda, or a class with a #call method.
  class BacktraceFilter

    def call(bt)
      return ["No backtrace"] unless bt and !bt.empty?

      new_bt = []

      unless $DEBUG then

        if bt.first =~ %r{^/.*?/lib/micron/test_case/assertions.rb:\d+:in} then
          # first line is an assertion, pop it off
          bt.shift
        end

        bt.each do |line|
          break if line =~ %r{(bin|lib)/micron}
          new_bt << line
        end

        # make sure we didn't remove everything - if we did, the error was in our code
        new_bt = bt.reject { |line| line =~ %r{(bin|lib)/(micron|zeus|spork)} } if new_bt.empty?
        new_bt = bt.dup if new_bt.empty?
      else
        new_bt = bt.dup
      end

      new_bt
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
micron-0.5.1 lib/micron/runner/backtrace_filter.rb