Way beyond cool: autotest + growl + Doomguy

Here’s something that will amaze your friends to no end. Your male geek friends, that is. Type some code in your editor, save file and… a smiling Doom Marine tells you that all your tests passed. Or, if there were some errors, the Marine is bleeding. The more errors, the more blood. Is it cool or is it cool?

Just look at the screenshots. First: Marine is happy that your tests passed.

The Doom Marine is happy that your tests passed.

Next: there were some failures. The blood starts to flow!

The blood starts to flow.

Even more failures, even more blood.

Even more failures, even more blood.

Oh my, it looks like we killed him, we bastards!

Oh my, it looks like we killed him, we bastards!

How to do this? Read on.

Inspiration

First, go and read Autotest Growl Pass/Fail Notifications by John Nunemaker. This is where I got inspiration from (the comments section, specifically). The Doom Marine head sprites can be found here http://sdb.drshnaps.com/sheets/Misc/Misc/Other/Doom-Head.png.

Prerequisites

For this all to work, you need Mac OS X, Growl notification application (with growlnotify), and autotest — automated testing utility. If you want it to look exactly as on screenshots above, set display style to ‘Music video’ in your Growl preferences.

The script

Now, if all prerequisites are installed, copy following script (this is John Nunemaker’s script with my tiny modifications) and save it as ~/.autotest file.

require 'autotest/redgreen'
require 'autotest/timestamp'    

module Autotest::Growl
  def self.growl title, msg, img, pri=0, sticky=""
    system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
  end
  Autotest.add_hook :ran_command do |at|
    image_root = "~/.autotest_images"
    results = [at.results].flatten.join("n")
    output = results.slice(/(\d+)\stests,\s(\d+)\sassertions,\s(\d+)\sfailures,\s(\d+)\serrors/)
    if output
      if $~[3].to_i > 0 || $~[4].to_i > 0
        cnt = [(9 + $~[3].to_i + $~[4].to_i) / 10 * 10, 50].min
        growl "FAIL", "#{output}", "#{image_root}/fail#{cnt}.png", 2
      else
        growl "Pass", "#{output}", "#{image_root}/pass.png"
      end
    end
  end
end

My addition is that depending on number of your failures and errors, one of 5 different failure icons is chosen.

The icons

You can download them from RapidShare (please let me know if the file is gone). The zip file contains one smiling Marine, five differently bleeding Marines and the above .autotest script in case you have any trouble with copying & saving stuff. After saving the zip file in your home directory, fire up your console and say:

~ > unzip doom.zip
Archive:  doom.zip
  inflating: .autotest
  inflating: .autotest_images/fail10.png
  inflating: .autotest_images/fail20.png
 extracting: .autotest_images/fail30.png
 extracting: .autotest_images/fail40.png
  inflating: .autotest_images/fail50.png
 extracting: .autotest_images/pass.png

And that’s all. Try running autotest and enjoy endless Doomguy goodness.

So you don’t use autotest?

Are you of those that refuse to accept the goodness of automated test running? Or maybe you don’t use Ruby at all? Don’t despair. As you can see the heart of this is the neat growlnotify utility. It should be as easy to add it to rake test. Or to report results of your ant or make build. Or anything really.

If you have any problems or questions, feel free to comment. I will be also glad to hear of any additional ideas where this could be used.

If you cannot download the above mentioned zip file from RapidShare, here are the icons again. Click on each and save to ~/.autotest_images:

passfail10fail20fail30fail40fail50

Add to:
Digg! digg blog_head.png reddit delicioussmall.gif del.icio.us

~ by szeryf on 2007-07-30.

28 Responses to “Way beyond cool: autotest + growl + Doomguy”

  1. I sent Doomworld a link to this and they featured it! http://www.doomworld.com/vb/doomworld-news/40885-the-doomguy-is-a-pedagogue/ .

  2. This is awesome. Perhaps you can pull together the doom sound effects for my new autotest plugin :)
    http://fozworks.com/2007/7/28/autotest-sound-effects

  3. The sound effects would be cool, but a little troublesome in the long run. Imagine a team of four coders running autotest with Doom sound effects simultaneously :)

  4. Exactly… “are you guys havin’ a LAN party? We gotta ship ASAP!!”

    “Nope we’re coding! Serious!”

  5. Wow. Awesome. Maybe I should comment on more blogs about stuff I want and they’ll appear.

  6. 13c13
    output = results.slice(/(\d+)\sexamples,\s(\d+)\sfailures/)
    15,16c15,16
    0 || $~[4].to_i > 0
    if $~[2].to_i > 0
    > cnt = [(9 + $~[2].to_i) / 10 * 10, 50].min

    To get it going with rspec.

  7. Ah crap

    13c13
    < output = results.slice(/(\d+)\stests,\s(\d+)\sassertions,\s(\d+)\sfailures,\s(\d+)\serrors/)

    > output = results.slice(/(\d+)\sexamples,\s(\d+)\sfailures/)
    15,16c15,16
    < if $~[3].to_i > 0 || $~[4].to_i > 0
    < cnt = [(9 + $~[3].to_i + $~[4].to_i) / 10 * 10, 50].min

    > if $~[2].to_i > 0
    > cnt = [(9 + $~[2].to_i) / 10 * 10, 50].min

  8. we’re gonna need a duke nukem version of this. can anyone say “Groovy.”

  9. Anyone wanna repost the icons? The file-upload link is dead.

  10. I re-uploaded the zip with icons, so it should last another few weeks. Anyone care to suggest a site where the files last longer?

    Sadly I cannot upload zip directly to wordpress.

    I could post all the icons as png files, but that would require clicking and saving each one separately.

  11. host the files on amazon s3

  12. P.S.: Can you post the icons again?

  13. The icons link works for me. But if you have any problems, here’s a new link: http://files-upload.com/files/527214/doom.zip

  14. I didn’t realize they were hidden in the folder!

  15. Sorry. You can not download this file today. Download traffic for your country is empty.

    How about Radpidshare.com?

  16. Sorry there was a typo: http://www.Rapidshare.com

  17. Art: the icons link is still working for me :)

    I also posted another link 3 comments above and it works, too.

    But if you have any problems, here’s your Rapidshare link: http://rapidshare.com/files/61103292/doom.zip.html

  18. It says: “Download traffic for your country is empty”. I guess your country is not affected :).
    However, rapidshare is a great site for sharing and there are no time limitations afaik.
    Thank you for the promt reply, but now I have a new problem. Nothing happens when tests fails or pass. I see no notification. Any idea how to get some response from autotest? Some error log or something?

  19. Sorry for spamming again, but now it works. I created the .autotest file myself before. Now I use yours from the zip file.

  20. Wierz mi lub nie, gęba kolesia z Dooma spowodowała, że będę dążył do 100% obłożenia kodu testami/specami.

  21. [...] Way beyond cool: autotest + growl + Doomguy « require ‘brain’ (tags: autotest ruby rubyonrails testing rails doom growl) [...]

  22. Ohhh GREAT!

    TO THE AUTHOR:
    It would be possible to make something similar for Linux?

  23. I create a gem to do it in a Linux and Mac.
    http://www.nomedojogo.com/2008/06/17/autotest-notification-doom-edition/

  24. Why be limited to on red/green sound. Why not try the playlist :)
    http://www.metaskills.net/2008/4/6/autotest-playlist-for-red-green-feedback

  25. [...] as you make changes.  And if you like to have your tests running automatically and you use Growl – this might be for [...]

  26. Thanks for the tips

  27. You might want to check http://github.com/Hates/doomguy-growl-autotest/tree/master. It looks like somewhat extended version of my idea.

  28. this is really really cool man!… thanks for the idea.

Leave a Reply