-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.autotest
executable file
·64 lines (55 loc) · 1.96 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
53
54
55
56
57
58
59
60
61
62
63
64
# NOTE Copy this to your home folder as .autotest
#
# Originally from http://wincent.com/knowledge-base/Setti … _use_Growl
#
# Modifications:
# * Minor refactoring to use .autotest_images directory
# [Geoffrey Grosenbach http://peepcode.com]
# * Test::Unit compatibility [Pat Nakajima]
#
module Autotest::Growl
AUTOTEST_IMAGE_ROOT = "/volumes/SERVER/growl_images/"
def self.growl title, msg, img, pri=0, sticky=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
end
def self.growl_fail(output)
growl "FAIL", "#{output}", "#{AUTOTEST_IMAGE_ROOT}/rails_fail.png", 2
end
def self.growl_pending(output)
growl "PENDING", "#{output}", "#{AUTOTEST_IMAGE_ROOT}/pending.png", 2
end
def self.growl_pass(output)
growl "PASS", "#{output}", "#{AUTOTEST_IMAGE_ROOT}/rails_ok.png"
end
Autotest.add_hook(:initialize) {|at|
at.add_exception %r{^\.git} # ignore Version Control System
at.add_exception %r{^./tmp} # ignore temp files, lest autotest will run again, and again...
at.clear_mappings # take out the default (test/test*rb)
at.add_mapping(%r{^lib/.*\.rb$}) {|f, _|
Dir['spec/**/*.rb']
}
nil
}
Autotest.add_hook :ran_command do |at|
results = [at.results].flatten.join("\n")
if results.include? 'tests'
output = results.slice(/(\d+)\s+tests?,\s*(\d+)\s+assertions?,\s*(\d+)\s+failures?(,\s*(\d+)\s+errors)?/)
if output
$~[3].to_i + $~[5].to_i > 0 ? growl_fail(output) : growl_pass(output)
end
else
# output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+not implemented)?/)
output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
if output =~ /[1-9]\sfailures?/
growl_fail(output)
elsif output =~ /[1-9]\spending?/
growl_pending(output)
else
growl_pass(output)
end
# if output
# $~[2].to_i > 0 ? growl_fail(output) : growl_pass(output)
# end
end
end
end