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.

Andy Stewart, 22 March 2007

Posted in Rails, Ruby


Have your say

You can use Markdown in your comments. If you want to post code, do this:

<pre><code class="ruby|javascript|css|html">your code here</code></pre>

Thanks!