Autotest notifications in KDE using DCOP and KNotify

Tests failed warning window

I recently came across a killer ruby application called autotest, which is part of a package called Zentest.

Geoffrey Grosenbach’s Nuby on Rails blog explains how to use autotest with Rails. It’s pretty simple, install Zentest:

gem install ZenTest

and from the Rails project’s root, type:

autotest -rails

Monitoring a console for failed tests is annoying and keeping an open console on-screen is too screen real-estate expensive on a 14 inch laptop. Enter KNotify and DCOP.

Create a file called .autotest in your home directory and paste the following code into it:

1
2
3
4
5
6
7
8
9
10
#!/usr/bin/ruby
module KDENotify
  def self.knotify title, msg
    system "dcop knotify default notify " +
           "eventname \'#{title}\' \'#{msg}\' '' '' 16 2"
  end
  Autotest.add_hook :red do |at|
    knotify "Tests failed", "#{at.files_to_test.size} tests failed"
  end
end

Once autotest is started and coding has commenced, a passive pop-up window will appear as soon as a saved file has caused a test to fail.

This is all made possible by autotest’s excellent design along with the genius that is KDE.

8 Responses to “Autotest notifications in KDE using DCOP and KNotify”

  1. Simon Says:

    Thanks - very useful :)

  2. zenspider Says:

    may I steal that?

  3. Geir Says:

    zenspider: sure you can! If you post the code in a blog, a referring link over to this one here wouldn’t go amiss :)

  4. Yet another autotest desktop notifier … OSD « Geekvicious Journal Says:

    […] post info By geekvicious Categories: ruby, linux and programming Being a big KDE fan I was glad when the people at snailbyte came up with KDE desktop notifier for autotest. Even though KDE is by far my favorite desktop environment, knofity has a big drawback; it is not possible to choose the color, for the notifications. So based in the growl autotest notifier, I wrote a version for osdsh an X OSD manager, it is not as pretty as growl ;)… but it gives me colorized on desktop notifications on linux. […]

  5. Eric Davis Says:

    Works perfect. Thank you.

  6. theAdmin.org Says:

    Fail Loudly with osd_cat and autotest…

    A key to Test Driven Development is frequently run tests. These tests are used to judge the health of a project. Like in a hospital, when things deteriorate we have to be alerted right away.

    Ruby developers use autotest to monitor and run their test…

  7. sarniak Says:

    I pasted this code to .autotest file nad nothing happens while I’m saving files (test fails, but I can see this only from console). Could somebody tell me, what can be wrong?

  8. RunRails-Blog » Blog Archive » Autotest-Notification unter GNOME über libnotify Says:

    […] Notifications unter OS X ausgerufen wurden. Später stieß ich zufällig auf einen interessanten Blog-Beitrag, wie solche Meldungen unter KDE erzeugt werden können. Ich setze GNOME als Arbeitsumgebung ein und habe mir ein ähnliches Skript […]

Leave a Reply