Fixing Snarl and autotest_menu in windows

I’ve been trying to get ZenSpider autotest and Windows to play nice for a while. First, I had the problem where autotest would only run once and not stick around waiting for updates to my code. That was fixed by Luke Pearce. He commented on a previous post with his fix and I can confirm that it works. Thanx Luke!

I encountered another problem now. When I ran my autotest but tried to shut it down by hitting Control-C twice in a row, the tests would just reset and run again. Double Control-C is supposed to interrupt the process and allow me to shut it down. This it did not do.

I am also running the autotest/menu plugin that is supposed to explicitly ask you whether you want to quit, restart or just keep going when you hit Control-C, even if it’s just hitting it once. This is the best possible option and is what I recommend, but it wasn’t happening. There were no prompts to quit, continue, or restart. Just restarting the entire test suite EVERY time I hit Control-C, whether it was two quick hits or 10 hits a row.

I originally looked at the code thinking that I should fix it there. Autotest provides hooks into it’s process. Run, interrupt, quit, etc. I figured it had to do with one of those so I first tried just commenting out the :interrupt hook code on lines 39-41 in ZenTest-4.0.0/lib/autotest/snarl.rb. This worked and I was happy. However it still didn’t feel right. I didn’t want to hack the code and ask them to fix it. It must be working for other people because I haven’t seen other people complaining about it.

Turns out the fix is a really easy one and requires no hacking on the gem code at all. It was just a problem with the order of my “require” lines in my .autotest file. My original .autotest file looked like this…

require 'redgreen/autotest'
require 'Win32/Console/ANSI'
require 'autotest/snarl'
require 'autotest/menu'
require 'autotest/timestamp'

The .autotest file that WORKS swaps the “snarl” and “menu” lines around, like so…

require 'redgreen/autotest'
require 'Win32/Console/ANSI'
require 'autotest/menu'
require 'autotest/snarl'
require 'autotest/timestamp'