autotest+mumbles for Growl like notifications

I was working with a colleague today who was kind enough to introduce me to autotest for continuous test integration. Change a file in your app & tests are automatically run for you… Nice.

my mumble alert

screenshot of my mumble alert (top-right)

One thing that really stood out aesthetically was how status messages were passed to Growl (in OSX) for eye-pleasing popup notifications outside of a terminal window.

Being a ubuntu user, I started looking for a similar solution for linux. It turns out there is a great utility for linux that resembles Growl — it’s called Mumbles. The challenge was getting Mumbles to work with autotest.

After searching google, I found one post that got me started. This is a good post, but I had to fill in a few blanks to get everything to work.

Here’s what I did:

  1. Install ZenTest:
  • sudo gem install ZenTest
  1. Install Mumbles
    • grab the latest .deb file or source from the mumbles-project page:
    • wget https://sourceforge.net/project/showfiles.php?group_id=193587&package_id=227998
    • test out mumbles by running:
    • mumbles &
    • mumbles-send ‘a title’ ‘it works!!’
    • assuming mumbles has been installed correctly, you should see a little notification pop up. I recommend that at this point you add mumbles to your system session so it will start when you login to ubuntu.
    • gnome-session-properties
    • add -> “mumbles” for name & command -> ok
  2. Install ruby-dbus. I could not find a gem, so install manually:
    • irb
    • irb(main):001:0> require ‘dbus’
    • => true
  3. Create a .autotest file in your application root directory (or your home directory to make the settings global) Thanks to CaffinatedCode for this script — they wrote it:
  • require ‘dbus’def send_message(title, message, icon)
    begin
    bus = DBus::SessionBus.instance
    mumbles_service = bus.service(“org.mumblesproject.Mumbles”)
    mumbles = mumbles_service.object(“/org/mumblesproject/Mumbles”)
    mumbles.introspect
    mumbles_iface = mumbles[“org.mumblesproject.Mumbles”]
    sig = mumbles_iface.signals[“Notify”]
    bus.emit(mumbles_service, mumbles, mumbles_iface, sig, title, message, icon)
    rescue Exception => e
    end
    end

    Autotest.add_hook :ran_command do |at|
    begin
    output = at.results.last.slice(/(\d+) examples?, (\d+) failures?(, \d+ pending)?/)
    if output =~ /.*[1-9] failure.*/ then
    send_message(“FAIL”, “#{output}”, “fail.png”)
    else
    send_message(“PASS”, “#{output}”, “pass.png”)
    end
    rescue Exception => e
    end
    end

Now for the fun part. From within your app root, type:

autotest

If everything works out, you should see a few things flash by – I get a error about “Insecure world writable dir” in my home dir. I just ignored that. After that, you should see a test summary in the terminal window, followed by a mumbles popup notificaton. Kick ass!

Advertisements