Suggestion for filtering your stack traces with Test::Unit::Util::BacktraceFilter

Most of the time, I don't want to see the whole stack trace including
the environment - I just want to see my code. So, I tossed this in my
test:

module Test
  module Unit
    module Util
      module BacktraceFilter
        def filter_backtrace_with_only_my_code(backtrace, prefix=nil)
          result = filter_backtrace_without_only_my_code backtrace, prefix
          result.reject! {|x| x =~ /ruby.lib.ruby/}
          result.reject! {|x| x =~ /vendor.plugins.mocha/}
          result
        end
        alias_method_chain :filter_backtrace, :only_my_code
      end
    end
  end
end

You'll probably want to play around with what gets filtered in and
out. I think of this sort of thing as more of a debugger macro than
actual code; it gets changed constantly depending on what I'm doing.

Hi James,

Most of the time, I don't want to see the whole stack trace including
the environment - I just want to see my code. So, I tossed this in my
test:
[snip]
You'll probably want to play around with what gets filtered in and
out. I think of this sort of thing as more of a debugger macro than
actual code; it gets changed constantly depending on what I'm doing.

That looks really useful. Thanks.

I felt the same way when running tests using Autotest and came up with a similar solution, though mine's confined to Autotest:

http://blog.airbladesoftware.com/2007/3/22/filtering-autotest-s-output

Regards,
Andy Stewart