-
Notifications
You must be signed in to change notification settings - Fork 0
/
.autotest
52 lines (42 loc) · 1.57 KB
/
.autotest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'autotest/redgreen'
Autotest.add_hook :initialize do |at|
at.clear_mappings
# watch out: Ruby bug (1.8.6):
# %r(/) != /\//
at.add_mapping(%r%^spec/.*_spec.rb$%) { |filename, _|
filename
}
at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
["spec/#{m[1]}_spec.rb"]
}
at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
at.files_matching %r%^spec/.*_spec\.rb$%
}
end
module Autotest::Growl
def self.growl title, msg, image=nil, pri=0
title += " in #{Dir.pwd}"
system "growlnotify -n autotest --image #{image || "/Applications/Mail.app/Contents/Resources/Caution.tiff"} -p #{pri} -m #{msg.inspect} #{title}"
end
Autotest.add_hook :initialize do |at|
growl "autotest running", "Started",'~/.autotest_images/pass.png'
end
Autotest.add_hook :reset do |at|
# growl "autotest reset", "Reset",'~/.autotest_images/pending.png'
end
Autotest.add_hook :red do |at|
output = at.results.match(/(\d+)\sfailure/)
if(output[1].to_i > 0)
cnt = [(9 + output[1].to_i) / 10 * 10, 50].min
growl "Tests Failed", "#{output[1]} tests failed", "~/.autotest_images/fail#{cnt}.png", 2
else
growl "Tests Passed", "All tests passed", '~/.autotest_images/pass.png',2 if at.tainted
end
end
Autotest.add_hook :green do |at|
growl "Tests Passed", "#{at.results.scan(at.completed_re)}", '~/.autotest_images/pass.png',2 if at.tainted
end
Autotest.add_hook :all_good do |at|
growl "All Tests Passed", "#{at.results.scan(at.completed_re)}", '~/.autotest_images/pass.png',2 if at.tainted
end
end