[Rake-devel] Hooking into rake test tasks

James Mead jamesmead44 at gmail.com
Thu Apr 17 13:38:29 EDT 2008

I'm sure there's probably a better way of doing this, but I've just hacked
together a simple patch for Rake which allows the following syntax...

  Rake::TestTask.new(:units => "db:test:prepare") do |t|
    t.libs << "test"
    t.pattern = 'test/unit/**/*_test.rb'
    t.verbose = true
    t.on_result = lambda do |ok, status|
      # do stuff here

The new bit is the "on_result" bit which allow you to specify a Proc to be
executed when the Ruby process executing the tests completes. The ok &
status parameters allow you to determine whether or not the tests have all
passed or not. The patch makes use of the fact that FileUtils#ruby and
FileUtils#sh allow you to pass in a block to be executed after the command

Would you be interested in the patch? If yes, is there somewhere to submit
it - the normal Tracker stuff on Rubyforge doesn't seem to be enabled for

Or can someone tell me a better way?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rake-devel/attachments/20080417/cd96e309/attachment.html 

More information about the Rake-devel mailing list