Skip to content

Instantly share code, notes, and snippets.

@roopeshvaddepally
Created July 19, 2011 05:22
Show Gist options
  • Save roopeshvaddepally/1091373 to your computer and use it in GitHub Desktop.
Save roopeshvaddepally/1091373 to your computer and use it in GitHub Desktop.
autotest for ubuntu 11.04
#!/bin/ruby
# ~.autotest
# require 'autotest_notification'
# SPEAKING = false
# DOOM_EDITION = false
# BUUF = false
# PENDING = false
# STICKY = false
# SUCCESS_SOUND = ''
# FAILURE_SOUND = ''
# require 'redgreen'
require 'autotest/timestamp'
module Autotest::GnomeNotify
def self.notify title, msg, img
system "notify-send '#{title}' '#{msg}' -i #{img} -t 3000"
end
Autotest.add_hook :initialize do |autotest|
autotest.add_mapping(%r%^spec/(requests)/.*rb$%) do |filename, _|
filename
end
end
Autotest.add_hook :ran_command do |at|
image_root = "~/.autotest_images"
results = [at.results].flatten.join("\n")
results.gsub!(/\\e\[\d+m/,'')
output = results.slice(/(\d+)\sexamples?,\s(\d+)\sfailures?(,\s(\d+)\spending?|)/)
full_sentence, green, failures, garbage, pending = $~.to_a.map(&:to_i)
if output
if failures > 0
notify "FAIL", "#{output}", "#{image_root}/fail.png"
elsif pending > 0
notify "Pending", "#{output}", "#{image_root}/pending.png"
else
notify "Pass", "#{output}", "#{image_root}/pass.png"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment