A moron once wrote:
> I have a similar problem; I'd like some of my test programs
> to generate other test programs on the fly, then run them.
>
> This seems to work:
>
> use strict;
> use Test::Harness;
> my $outf = 'out.tmp';
> print "1..1\n";
> local *SAVOUT; open(SAVOUT, ">&STDOUT");  # save original STDOUT
> open(STDOUT, '>'.$outf) or die "error: open '$outf': $!";
> my $success = runtests('t/some_generated_test.t');
> open(STDOUT, ">&SAVOUT");                 # restore STDOUT
> $success or print "not ";
> print "ok 1\n";
>
> but I feel odd.

Hey Schwern! How come you let this stand? Looks like you gave the right
advice tonight in huesserm's use.perl.org journal:

"A more general solution is in TieOut.pm of which copies are scattered
around in t/lib directories of various modules, a little invention of
chromatic's. Here's one.
http://search.cpan.org/src/MSCHWERN/ExtUtils-MakeMaker-6.16/t/lib/. Here's
an example of its use.
http://search.cpan.org/src/MSCHWERN/ExtUtils-MakeMaker-6.16/t/prompt.t
That also shows TieIn for input filehandles.

Yes, one of these days I'll get around to writing Test::Filehandles. Hey,
someone could pay me to write it! ;)"

Or am I missing something? (again).

/-\


http://search.yahoo.com.au - Yahoo! Search
- Looking for more? Try the new Yahoo! Search

Reply via email to