Re: [Module::Build] Capturing test output to please CPANPLUS
Status: Beta
Brought to you by:
kwilliams
|
From: Randy W. S. <ml...@th...> - 2006-05-16 09:29:34
|
Ken Williams wrote:
>
> On Apr 10, 2006, at 1:46 AM, Randy W. Sims wrote:
>
>> Randy W. Sims wrote:
>>
>>> Will something like this work for a temporary solution that we can
>>> maybe figure out how to extend in the future to always capture output?
>>
>>
>> Regarding Ticket #9793 [1]
>>
>> Scratch that. I don't really like my previous solution. I'm not sure
>> Module::Build needs to be responsible for capturing output; I can't
>> really see any benifit. Is there a reason CPANPLUS (or
>> CPANPLUS::Dist::Build) can't do this, like below (borrowing again
>> from Jos' patch), or are there other issues I'm not aware of?
>
>
> Probably as much as possible should go in CPP:D:Build, unless there are
> aspects of it that would also be nice to have in the core, and they
> wouldn't generate too much clutter.
>
> In general I'm leery of messing with filehandles too much in the core,
> because the people can't do their own messing if they want to.
I've been sitting on the attached patch against CPANPLUS::Dist::Build
for a while because 1) I'm not knowledgeable about CPANPLUS to know how
to properly test it; and 2) it still has the problem of suspending
output until the test completes before sending to stdout.
I thought maybe I could extend the patch a little further to use IO::Tee
to eliminate the delayed output, but it doesn't seem to work:
#!/usr/bin/perl
use File::Spec;
chdir( File::Spec->catdir( glob('~'), 'Module-Build' ) );
use Module::Build;
my $mb = Module::Build->new_from_context;
$mb->dispatch('build');
require IO::String;
my $io = IO::String->new;
require IO::Tee;
my $tee = IO::Tee->new(\*STDOUT, $io);
my $SAVE_OUT = select($tee);
$mb->dispatch('test', test_files => 't/runthrough.t', verbose => 1);
select($SAVE_OUT);
my $result = ${$io->string_ref};
# craft a report from $result . $@
__END__
This works fine when tests succeed, but when there is a failure in the
test...
# Looks like you failed 1 test of 33.
dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED test 1
Failed 1/33 tests, 96.97% okay (less 4 skipped tests: 28 okay,
84.85%)
Undefined format "Symbol::GEN128" called at
/usr/share/perl/5.8/Test/Harness.pm line 542.
Anyone know how to make this work, please?
Randy.
|