Sorry this page looks weird. It was automatically migrated from my old blog, which had a different layout and different CSS.

Filtering Autotest’s Output

Update: this works with Autotest up to version 3.5.0. See here for what to do with versions 3.5.0 and up.

Autotest is one of the few tools I use that I regard as essential. I can’t imagine how I ever lived without it.

Recently, however, I noticed the rapid feedback loop was slowing down. The huge stack traces dumped to the console whenever I mis-coded were hard to decipher at a glance. I want to see the execution path through my own code; but 95% of the trace was the path through the Rails libraries.

How to filter out the Rails libraries? Happily Autotest is beautifully written. The code reads like English and hooks are thoughtfully provided everywhere you might want to hang your coat, er, code. Filtering the stack trace is this simple:

~/.autotest.rb:

Autotest.add_hook :ran_command do |autotest|
  autotest.results.gsub!(%r{^.*/usr/local/lib/.*\\n?}, '')
end

Pop that into ~/.autotest, restart Autotest and voilà! Clean, easy to grasp stack traces.

Comments

Super great article. Honestly!

Yvette Mendez • 28 May 2010

Andrew Stewart • 22 March 2007 • RailsRuby
You can reach me by email or on Twitter.