On Fri, Feb 11, 2005 at 07:30:24AM -0500, David Golden wrote: > Very nice integration of IO::Capture. > > I think this is very promising, but all the start(), stop() calls seem > overly repetitive to me. What about refactoring it into a set of test > functions that handle it for the user automatically? Just quickly off the > cuff, what about a test module (Test::Output? Test::Print? ) that provided > functions like this: > > stdout_is { fcn() } $string, "comment"; # exact > stdout_like { fcn() } qr/regex/, "comment"; # regex match > stdout_count { fcn() } qr/regex/, $count, "comment"; # number of matches > stdout_found { fcn() } qr/regex/, [EMAIL PROTECTED], "comment"; # list of > matches
The trouble with this interface is sometimes you want to collect a bunch of output from a bunch of different functions together. What the little TieOut module that MakeMaker and Test::More uses is it provides an object and a read() method. read() is destructive, when called it returns whatever was in the buffer and wipes the buffer clean. This way you can collect as much as you want in a natural way without having to use start/stop functions or shoving everything into a block.