header image
 

Mumble your tests!

mumbles screenshot
I’ve been working on a rails project, and in some screen cast, I saw autotest+growl and fell in love. I googled a bit for a Linux version of growl, and I found Mumbles. There was no built in autotest support, so I hacked around, extended the Mumbles dbus interface just a little, and then made a simple autotest hook that uses Mumbles.

Until the author commits my patch to his repository, you can get my patched version as a tarball here: Mumbles patched (its a bziped tarball, not a jpeg file - wordpress limitations, so right-click and save as)

And here’s the autotest plugin:


require 'dbus'

def send_message(title, message, icon)
  begin
    bus = DBus::SessionBus.instance
    mumbles_service = bus.service("org.mumblesproject.Mumbles&quot ;)
    mumbles = mumbles_service.object("/org/mumblesproject/Mumbles&quot ;)
    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&quot ;)
     else
       send_message("PASS", "#{output}", "pass.png&quot ;)
     end
  rescue Exception => e
  end
end

You’ll need the ruby-dbus library which you can get here

*Update:* surrounded the hook with begin rescue. Without this, autotest would crash if I had a syntax error in my spec, because at.result.last would be nil

~ by hellfeuer on February 22, 2008.

11 Responses to “Mumble your tests!”

  1. I’d be cool if you posted a screenshot :) :)

  2. Screenshots for Mac version using growl are on my blog here: http://szeryf.wordpress.com/2007/07/30/way-beyond-cool-autotest-growl-doomguy/

  3. You can have growl-like notifications even simpler without mumbles using the builtin (?) libnotify and notify-send. I found a tutorial here (http://ph7spot.com/articles/getting_started_with_autotest) and it works very well.

  4. Sorry I’ve been away for really long. The screenshot is up now, and Andreas, I know about libnotify, I was searching for something better looking :)

    There have been some changes made to the Mumbles autotest plugin, and hopefully they’ll be in the SVN repository soon. Until then, this method still works.

  5. Thanks! This is just I’m looking for!

  6. [...] Looks like they use it to get notifications about automated tests. And then he found mumbles and re-worked his [...]

  7. the code above, when cut-and-pasted, gives me tons of errors. encoding issue?

  8. it worked for me like this:

    require ‘dbus’

    def send_message(title, message, icon)
    begin
    bus = DBus::SessionBus.instance
    mumbles_service = bus.service(”org.mumblesproject.Mumbles&quot “ ;)
    mumbles = mumbles_service.object(”/org/mumblesproject/Mumbles&quot “ ;)
    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&quot “ ;)
    else
    send_message(”PASS”, “#{output}”, “pass.png&quot “ ;)
    end
    rescue Exception => e
    end
    end

  9. mumbles has growl support, now, actually (version 0.4-1)

  10. Yeah, mumbles has support for growl network notifications. Not sure how you would use that to get autotest notifications, since people mostly really on growlnotify in their autotest hook which of course won’t be available on linux

  11. Just what I was looking for. Thanks for sharing!

Leave a Reply