-
Notifications
You must be signed in to change notification settings - Fork 3
/
tests.watchr
58 lines (50 loc) · 1.39 KB
/
tests.watchr
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
# Run me with:
# watchr -d tests.watchr
#
# Also requires the Watchr and ruby-growl gems as well as JSHint,
# JSLint and PHP CodeSniffer. Install them thusly:
#
# sudo gem install watchr ruby-growl
#
# To use fsevent you currently have to patch watchr.rb as described here:
# https://github.com/mynyml/watchr/issues/36#issuecomment-7794856
# Then
# sudo gem install rev
@growl_clients = %w{
127.0.0.1
}
def check action, title, message
guid = %x{echo '#{title}' | sha1sum - | cut -d' ' -f1}.chomp
if system %{set -x; #{action}}
if system %{test -e /tmp/#{guid}}
puts "\033[32;1m" + title + " RECOVERY\n\t" + message + "\033[0m"
system %{rm /tmp/#{guid}}
@growl_clients.each do | host |
system %{growl -H #{host} -t 'RECOVERED OK: #{title}' -m '#{message}'}
end
end
else
puts "\033[31;1m" + title + " FAILURE\n\t" + message + "\033[0m"
system %{touch /tmp/#{guid}}
@growl_clients.each do | host |
system %{growl -H #{host} -t 'FAIL: #{title}' -m '#{message}'}
end
return false
end
return true
end
# Rules
#
# Less specific rules should be listed first.
watch( '(.*\.py$)' ) { |m|
check(%{tests/run},
"Tests for #{m[2]}",
m[1])
}
watch( '(.*bin/sparkler$)' ) { |m|
check(%{tests/run},
"Tests for #{m[2]}",
m[1])
}
# Press Ctl-C to quit.
Signal.trap('INT' ) { abort("\n") } # Ctrl-C