我正在尝试配置autotest,以便当我运行我的测试套件并且测试失败时,autotest停止测试,并等待我在再次测试之前进行更改。在我当前的配置下,autotest在遇到失败的测试时一直在进行无限期的测试,这让它变得有点麻烦(每次我得到失败的测试时,必须跳转到终端并停止自动测试服务器)。
我正在开发一个使用RSpec,Zentest和Spork的rails应用程序。
相关Gem版本:
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)我的.autotest文件:
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", 'critical', 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注意:我的大部分.autotest文件都是为了在我的测试通过或失败时显示在linux中工作的弹出窗口。
我已经寻找这个问题的答案有一段时间了,但一直没有运气,我发现很难为Autotest找到一些好的文档。我已经盯着Zentest的RDoc看了很长一段时间了,我肯定是错过了什么。
任何帮助,链接到例子等,将非常感谢。
发布于 2011-09-25 06:36:46
我也遇到了同样的问题,并且发现我的开发服务器正在向日志文件写入数据。在我将这段代码添加到我的.autotest文件中之后,问题就消失了:
Autotest.add_hook :initialize do |at|
at.add_exception(%r{^\./\.git})
at.add_exception(%r{^\./log})
end发布于 2011-07-13 18:49:10
当我有一个gem正在向ZenTest监视的目录写入数据时,我发现ZenTest也有类似的问题。IIRC,它是一个执行全文搜索的gem --搜索生成的索引文件触发ZenTest再次运行,从而重新生成索引。
我通过修改Growl通知来追踪这个问题,告诉我哪些文件触发了自动测试运行(当时我在Mac上运行)。
解决方案是向.autotest文件添加一个例外/排除,告诉它忽略索引。
(我刚刚看到:Spork is repeatedly re-running failing tests in autotest,听起来和你的问题非常相似)
https://stackoverflow.com/questions/6405556
复制相似问题