Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #!/bin/ruby
  2. #require 'redgreen'
  3. require 'autotest/timestamp'
  4.  
  5. module Autotest::GnomeNotify
  6. def self.notify title, msg, img
  7. system "notify-send '#{title}' '#{msg}' -i #{img} -t 3000"
  8. end
  9.  
  10. Autotest.add_hook :ran_command do |at|
  11. image_root = "~/.autotest_images"
  12. results = [at.results].flatten.join("\n")
  13. results.gsub!(/\\e\[\d+m/,'')
  14. output = results.slice(/(\d+)\sexamples?,\s(\d+)\sfailures?(,\s(\d+)\spending?|)/)
  15. full_sentence, green, failures, garbage, pending = $~.to_a.map(&:to_i)
  16. if output
  17. if failures > 0
  18. notify "FAIL", "#{output}", "#{image_root}/fail.png"
  19. elsif pending > 0
  20. notify "Pending", "#{output}", "#{image_root}/pending.png"
  21. else
  22. notify "Pass", "#{output}", "#{image_root}/pass.png"
  23. end
  24. end
  25. end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement