On Feb 11, 2005, at 2:44 PM, Michael G Schwern wrote:

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.




I've started working on Test::Output that is based on Schwern's TieOut module that comes with Test::More. I'm hoping to have it released on CPAN later tonight.

Test::Output is a self contained so that it can be included with other modules, and no prereqs. Right now it provides output_is() (combined STDERR, STDOUT), stderr_is(), and stdout_is(), but I plan to add _like, and _found shortly.

---
Shawn Sorichetti



Reply via email to