jimweirich/rake — pull request #148 by michaeljbishop (2012-11-20 03:42:14+00:00)
Title: Fix Application#trace which would interleave CR in a multi-threaded context

Running rake with tracing on and executing multitasks would show
a trace with multiple traces on a single line and other lines having
multiple CRs. This is because `#trace` used `IO#puts` behind the scenes.

`IO#puts` first calls `IO#write` with the string, followed by another `IO#write`
with the CR. Because of the gap in-between calls, another thread
could sneak in a CR or another string.

The fix is to make sure calls to `Application#trace` create a single string with
a CR appended before calling `IO#print`. This will output a single
string with a trailing CR in thread-safe way.

Example output showing the error:

** Execute 98** Execute 68** Execute 69

** Execute 74

** Execute 78** Execute 81
** Execute 84** Execute 100

** Execute 89