Skip to content

Instantly share code, notes, and snippets.

@eric
Created October 28, 2008 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eric/20526 to your computer and use it in GitHub Desktop.
Save eric/20526 to your computer and use it in GitHub Desktop.
My ~/.autotest
# My current ~/.autotest
require 'autotest/redgreen'
require 'autotest/restart'
# Images from http://blog.ardes.com/2008/5/23/leopard-autotest-growl-and-bob-the-builder
AUTOTEST_IMAGE_ROOT = File.expand_path(File.join(ENV['HOME'], 'Pictures', 'autotest'))
module Autotest::Growl
def self.growl(title, msg, img, pri=0)
system('growlnotify', '-n', 'autotest', '--image', img, '-p', pri.to_s, '-m', msg, '-t', title)
end
Autotest.add_hook :red do |at|
growl("Fail (#{project_name})", "#{get_results(at)}", "#{AUTOTEST_IMAGE_ROOT}/fail.jpg", 1)
end
Autotest.add_hook :green do |at|
growl("Pass (#{project_name})", "#{get_results(at)}", "#{AUTOTEST_IMAGE_ROOT}/ok.jpg")
end
private
def self.project_name
@project_name ||= File.basename(Dir.getwd)
end
# From http://tempe.st/2008/05/how-i-made-autotest-redgreen-and-growl-party-together/
def self.get_results(at)
unless output = at.results.slice(at.completed_re)
output = "#{at.files_to_test.length} files failed"
end
output
end
end
Autotest.add_hook :initialize do |at|
%w(.svn .hg .git vendor).each { |exception| at.add_exception(exception) }
false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment