Created
October 1, 2009 01:47
-
-
Save baron/198638 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#require 'autotest/growl' | |
require 'autotest/rcov' | |
# require 'autotest/html_report' | |
# require 'autotest/kdenotify' | |
# require 'autotest/menu' | |
#require 'autotest/pretty' | |
require 'autotest/redgreen' | |
# require 'autotest/snarl' | |
# require 'autotest/timestamp' | |
# These require growlnotify, but once you have that you can tweak priorities | |
# in the Growl control panel to get RedGreen in the growl bubble itself! | |
# http://growl.info/documentation/growlnotify.php | |
module Autotest::Growl | |
def self.growl title, msg, img, pri=0, stick="" | |
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}" | |
end | |
Autotest.add_hook :ran_command do |at| | |
#title = "Test Results" | |
title = "" | |
title << at.results.last | |
#output = at.results.join(' ').slice(/(\d+).*errors/) | |
output = at.results.to_s.gsub(/\n/,"-----") | |
if output =~ /ns.*[1-9]/ | |
growl title, "#{output}", '~/Library/autotest/rails_fail.png', 2 #, "-s" | |
else | |
growl title, "#{output}", '~/Library/autotest/rails_ok.png' | |
end | |
end | |
end | |
=begin | |
module Autotest::Growl | |
def self.growl title, msg, img, pri=0, stick="" | |
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}" | |
end | |
Autotest.add_hook :ran_command do |at| | |
output = at.results.to_s.gsub(/\n/," /// ") | |
if output =~ /ns.*[1-9]/ | |
growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2 #, "-s" | |
else | |
growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png' | |
end | |
end | |
end | |
=end | |
#module Autotest::Growl | |
# # def self.growl title, msg, pri=0, stick="" | |
# # system "growlnotify -n autotest --image /Users/baron/Documents/rails.png -p #{pri} -m #{msg.inspect} #{title} #{stick}" | |
# # end | |
# def self.growl title, msg, pri=0 | |
# title += " in #{Dir.pwd}" | |
# # msg += " at #{Time.now}" | |
# system "growlnotify -n autotest --image /Users/baron/Documents/rails.png -p #{pri} -m #{msg.inspect} #{title}" | |
# end | |
# Autotest.add_hook :ran_command do |at| | |
# output = at.results.to_s.slice(/(\d+).*errors/) | |
# if output =~ /ns.*[1-9]/ | |
# growl "Test Results", "#{output}", 2 | |
# else | |
# growl "Test Results", "#{output}" | |
# end | |
# end | |
#end | |
# module AutoGrowl | |
# def self.growl title, msg, pri=0 | |
# system "growlnotify -n autotest --image /Users/baron/Documents/rails.png -p #{pri} -m #{msg.inspect} #{title}" | |
# end | |
# | |
# Autotest.add_hook :run do |at| | |
# growl "Run", "Run" unless $TESTING | |
# end | |
# | |
# Autotest.add_hook :red do |at| | |
# growl "Tests Failed", "#{at.files_to_test.size} tests failed", 2 | |
# end | |
# | |
# Autotest.add_hook :green do |at| | |
# growl "Tests Passed", "All tests passed", -2 if at.tainted | |
# end | |
# | |
# Autotest.add_hook :init do |at| | |
# growl "autotest", "autotest was started" unless $TESTING | |
# end | |
# | |
# Autotest.add_hook :interrupt do |at| | |
# growl "autotest", "autotest was reset" unless $TESTING | |
# end | |
# | |
# Autotest.add_hook :quit do |at| | |
# growl "autotest", "autotest is exiting" unless $TESTING | |
# end | |
# | |
# Autotest.add_hook :all do |at|_hook | |
# growl "autotest", "Tests have fully passed", -1 unless $TESTING | |
# end | |
# end | |
# class Autotest | |
# | |
# # All code borrowed from: | |
# # http://www.robsanheim.com/2006/08/07/hacking-green-bar-color-output-into-autotest/ | |
# | |
# | |
# BAR = "=" * 80 | |
# | |
# # filter output for colorized green/red bar | |
# def filter_output(results) | |
# filtered = "" | |
# results.each do |line| | |
# | |
# if line =~ /\d+ tests, \d+ assertions, 0 failures, 0 errors/ | |
# line = "\e[32m#{BAR}\n#{$&}\e[0m\n\n" | |
# elsif line =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/ | |
# if $1 != 0 || $2 != 0 | |
# line = "\e[31m#{BAR}\n#{$&}\e[0m\n\n" | |
# end | |
# end | |
# filtered <<line | |
# end | |
# filtered | |
# end | |
# | |
# | |
# | |
# def run_tests | |
# find_files_to_test # failed + changed/affected | |
# cmd = make_test_cmd @files_to_test | |
# | |
# puts cmd | |
# | |
# @results = `#{cmd}` | |
# hook :ran_command | |
# puts filter_output(@results) | |
# | |
# handle_results(@results) | |
# end | |
# | |
# end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment