-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautotest
27 lines (23 loc) · 1.05 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
#!/usr/bin/env ruby
# Symlink this to ~/.autotest
require 'autotest/redgreen'
AUTOTEST_IMAGE_PATH = File.join(File.dirname(File.expand_path(__FILE__)), '.dotfiles', 'autotest_images')
module Autotest::Growl
def self.growl title, msg, img, pri=0, stick=""
system "growlnotify -n autotest --image #{img.inspect} -p #{pri} -m #{msg.inspect} #{title.inspect} #{stick}"
end
Autotest.add_hook :ran_command do |autotest|
filtered = autotest.results.grep(/\d+\s.*examples?/)
output = filtered.empty? ? "" : filtered.last.slice(/(\d+)\s.*examples?,\s(\d+)\s.*failures?(?:,\s(\d+)\s.*pending)?/)
if output =~ /[1-9]\sfailures?/
growl "Test Results", "#{output}", File.join(AUTOTEST_IMAGE_PATH, 'fail.png')
elsif output =~ /pending/
growl "Test Results", "#{output}", File.join(AUTOTEST_IMAGE_PATH, 'pending.png')
else
growl "Test Results", "#{output}", File.join(AUTOTEST_IMAGE_PATH, 'pass.png')
end
end
end
Autotest.add_hook :initialize do |at|
%w{.svn .hg .git vendor}.each {|exception| at.add_exception(exception)}
end