Skip to content

Instantly share code, notes, and snippets.

@pol
Created May 11, 2009 21:34
Show Gist options
  • Select an option

  • Save pol/110201 to your computer and use it in GitHub Desktop.

Select an option

Save pol/110201 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Symlink this to ~/.autotest
require 'autotest/redgreen'
# AUTOTEST_IMAGE_PATH = File.dirname(File.symlink?(__FILE__) ? File.readlink(__FILE__) : File.expand_path(__FILE__))
module Autotest::Growl
def self.growl title, msg, img, pri=0, stick=""
system "growlnotify -w -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}", "#{AUTOTEST_IMAGE_PATH}/fail.jpg"
growl "Test Results", "#{output}", "/Users/pol/Pictures/autotest/achewood/fail.jpg"
elsif output =~ /pending/
# growl "Test Results", "#{output}", "#{AUTOTEST_IMAGE_PATH}/pending.jpg"
growl "Test Results", "#{output}", "/Users/pol/Pictures/autotest/achewood/pending.jpg"
else
# growl "Test Results", "#{output}", "#{AUTOTEST_IMAGE_PATH}/ok.jpg"
growl "Test Results", "#{output}", "/Users/pol/Pictures/autotest/achewood/ok.jpg"
end
end
end
Autotest.add_hook :initialize do |at|
%w{.svn .hg .git vendor}.each {|exception| at.add_exception(exception)}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment