On 9/18/06, Ovid <[EMAIL PROTECTED]> wrote:
----- Original Message ----
From: Michael G Schwern <[EMAIL PROTECTED]>
> > What about an optional environment variable
> > which forcess *all* output to STDOUT or STDERR
> > but, if not present, leaves things as is?
>
> Did anyone think to try it?
>
> $ cat ~/tmp/stdout.t
> #!/usr/bin/perl -w
>
> use Test::More tests => 1;
>
> my $tb = Test::More->builder;
>
> $tb->failure_output( $tb->output );
>
> is 23, 42;
>
>
> $ perl -MTest::Harness -wle 'runtests @ARGV' ~/tmp/stdout.t
> /Users/schwern/tmp/stdout....dubious
> Test returned status 1 (wstat 256, 0x100)
> DIED. FAILED test 1
> Failed 1/1 tests, 0.00% okay
> Failed Test Stat Wstat Total Fail Failed List of Failed
>
-------------------------------------------------------------------------------
> /Users/schwern/tmp/stdout.t 1 256 1 1 100.00% 1
> Failed 1/1 test scripts, 0.00% okay. 1/1 subtests failed, 0.00% okay.
>
> Test::Harness throws out all non-TAP stuff going to STDOUT.
> This includes comments. So if Test::Builder started sending
> its diagnostics to STDOUT they'd disappear into the ether.
I have a bit of a problem, I think. It could simply be a matter of
misunderstanding how things work, but I have the following bit of code in
TAPx::Parser::Source::Perl:
my $sym = gensym;
if ( open $sym, "$command 2>&1 |" ) {
return TAPx::Parser::Iterator->new($sym);
}
else {
$self->exit($? >> 8);
$self->error("Could not execute ($command): $!");
warn $self->error;
return;
}
I've gotten a report that the open command fails on Windows. Not a surprise, now that
I think about it. However, I don't know of any portable way of forcing STDERR to
STDOUT (and I don't have a Windows box handy). This means that my 2000+ TAPx::Parser
tests are in trouble. If Test::Builder accepted an environment variable which allowed
me to override this, I might have a way out. So far removing the 2>&1 seems to
make my tests pass on a Linux box, but that strikes me as bizarre as I thought STDERR
wouldn't get read that way. What the heck am I misunderstanding?
The easiest way I know of to execute a process in win32 and get both
the stderr and stdout back is to use backticks.
my $res=`$cmd 2>&1`;
I guess you would have to wrap the result in something so that you get
an iterator over it, but it does work as you can see below.
D:\dev\cpan\re-0.0601>perl -e"my $r=`cl`; print qq(----\n); print $r"
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
Copyright (C) Microsoft Corporation 1984-2001. All rights reserved.
----
usage: cl [ option... ] filename... [ /link linkoption... ]
D:\dev\cpan\re-0.0601>perl -e"my $r=`cl 2>&1`; print qq(----\n); print $r"
----
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
Copyright (C) Microsoft Corporation 1984-2001. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
D:\dev\cpan\re-0.0601>
--
perl -Mre=debug -e "/just|another|perl|hacker/"