Guest User

Untitled

a guest
Mar 6th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. # Symlink this to ~/.autotest
  3. require 'autotest/redgreen'
  4.  
  5. # AUTOTEST_IMAGE_PATH = File.dirname(File.symlink?(__FILE__) ? File.readlink(__FILE__) : File.expand_path(__FILE__))
  6.  
  7. module Autotest::Growl
  8. def self.growl title, msg, img, pri=0, stick=""
  9. system "growlnotify -w -n autotest --image #{img.inspect} -p #{pri} -m #{msg.inspect} #{title.inspect} #{stick}"
  10. end
  11.  
  12. Autotest.add_hook :ran_command do |autotest|
  13. filtered = autotest.results.grep(/\d+\s.*examples?/)
  14. output = filtered.empty? ? "" : filtered.last.slice(/(\d+)\s.*examples?,\s(\d+)\s.*failures?(?:,\s(\d+)\s.*pending)?/)
  15. if output =~ /[1-9]\sfailures?/
  16. # growl "Test Results", "#{output}", "#{AUTOTEST_IMAGE_PATH}/fail.jpg"
  17. growl "Test Results", "#{output}", "/Users/pol/Pictures/autotest/achewood/fail.jpg"
  18. elsif output =~ /pending/
  19. # growl "Test Results", "#{output}", "#{AUTOTEST_IMAGE_PATH}/pending.jpg"
  20. growl "Test Results", "#{output}", "/Users/pol/Pictures/autotest/achewood/pending.jpg"
  21. else
  22. # growl "Test Results", "#{output}", "#{AUTOTEST_IMAGE_PATH}/ok.jpg"
  23. growl "Test Results", "#{output}", "/Users/pol/Pictures/autotest/achewood/ok.jpg"
  24. end
  25. end
  26. end
  27.  
  28. Autotest.add_hook :initialize do |at|
  29. %w{.svn .hg .git vendor}.each {|exception| at.add_exception(exception)}
  30. end
Add Comment
Please, Sign In to add comment