Zentest - How to stop automatic testing when red
I am trying to configure autotest so that when I run my test suite and I have a failing test, autotest stops testing and waits for me to make a change before testing again. With my current configuration autotest keeps testing indefinetly when it encounters a failing test making it a bit of a hassle to deal with (having to tab into terminal and stop the autotest server everytime I get a failing test).
I am working on a rails app using RSpec, Zentest and Spork.
Relevant Gem Versions:
autotest (4.4.6)
rspec (2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
spork (0.9.0.rc8)
ZenTest (4.5.0)
My .autotest file:
module Autotest::Notify
def self.notify title, msg, img, pri='low', time=3000
`notify-send -i #{img} -u #{pri} -t #{time} '#{msg}'`
end
Autotest.add_hook :ran_command do |autotest|
results = [autotest.results].flatten.join("\n")
output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
folder = "~/.autotest_icons/"
if output =~ /[1-9]\d*\sfailures?/
notify "FAIL:", "#{output}", folder+"failed.png", 'cr开发者_开发问答itical', 10000
elsif output =~ /[1-9]\d*\spending?/
notify "PENDING:", "#{output}", folder+"pending.png", 'normal', 10000
else
notify "PASS:", "#{output}", folder+"passed.png"
end
end
end
Note: Most of my .autotest file was to get popups working in linux to display if my tests are passing or failing.
I have been searching for an answer to this problem for a while and have had no luck and I have found it very difficult to get my hands on some good documentation for Autotest. I have been staring at the RDoc for Zentest for quite a while now as well and I must just be missing something.
Any help, links to examples, etc, would be greatly appreciated.
I had the same problem and found that my development server was writing to the log file. After I added this to my .autotest file, the problem went away:
Autotest.add_hook :initialize do |at|
at.add_exception(%r{^\./\.git})
at.add_exception(%r{^\./log})
end
I saw a similar problem with ZenTest when I had a gem that was writing data to a directory that ZenTest was monitoring. IIRC, it was a gem that did full-text searching -- the index file the search generated was triggering ZenTest to run again, thereby regenerating the index.
I tracked down the problem by modifying the Growl notifications to tell me which files were triggering the autotest run (I was running on a Mac at the time).
The solution was to add an exception/exclude to the .autotest file, to tell it to ignore the index.
(I've just seen : Spork is repeatedly re-running failing tests in autotest which sounds very similar to your problem)
精彩评论