[Rake-devel] [PATCH] Make Rake flush stdout

aslak hellesoy aslak.hellesoy at gmail.com
Sat May 27 13:13:41 EDT 2006


When Rake is run from another Ruby process (using IO.popen) the stdout
is not flushed appropriately, so stdout arrives at the parent process
later than it should - and in one big batch.

Here is why this matters: I'm running rake from Ruby with --trace,
looking for lines that match /^\*\* Execute (.*)$/. For each match I
record the timestamps for each task invocation. This allows me to
measure how long each task takes. I can store this information and
track how the duration of certain tasks evolve over time.

I'm attaching a patch that makes Rake flush stdout - plus a functional
test. The attached files go to test/test_flush.rb and
test/data/flush/Rakefile

It could be that the flush statements should go somewhere else - like
at the beginning and end of a task invocation, but this works for me.

Cheers,
Aslak
-------------- next part --------------
A non-text attachment was scrubbed...
Name: flush_stdout_when_executing_tasks.patch
Type: application/octet-stream
Size: 758 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/rake-devel/attachments/20060527/735fdf1f/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_flush.rb
Type: text/x-ruby-script
Size: 648 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/rake-devel/attachments/20060527/735fdf1f/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rakefile
Type: application/octet-stream
Size: 220 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/rake-devel/attachments/20060527/735fdf1f/attachment-0001.obj 


More information about the Rake-devel mailing list