Subject: | Test diag to stdout rather than stderr on TODO |
Date: | Tue, 23 Jun 2015 14:21:18 +0100 |
To: | bug-Test [...] rt.cpan.org |
From: | Dave Mitchell <davem [...] iabyn.com> |
If a TODO test fails, the diagnostic output should go to stdout rather
than stderr. This is part of my campaign to ensure that building
bleadperl is 'stderr' safe; i.e. that the only stuff going to stderr
should be real warnings and errors which need dealing with.
The following patch fixes this.
diff --git a/cpan/Test/lib/Test.pm b/cpan/Test/lib/Test.pm
index 108bc10..5cbf265 100644
--- a/cpan/Test/lib/Test.pm
+++ b/cpan/Test/lib/Test.pm
@@ -437,23 +437,24 @@ sub _complain {
my $diag = $$detail{diagnostic};
$diag =~ s/\n/\n#/g if defined $diag;
+ my $out = $$detail{todo} ? $TESTOUT : $TESTERR;
$$detail{context} .= ' *TODO*' if $$detail{todo};
if (!$$detail{compare}) {
if (!$diag) {
- print $TESTERR "# Failed test $ntest in $$detail{context}\n";
+ print $out "# Failed test $ntest in $$detail{context}\n";
} else {
- print $TESTERR "# Failed test $ntest in $$detail{context}: $diag\n";
+ print $out "# Failed test $ntest in $$detail{context}: $diag\n";
}
} else {
my $prefix = "Test $ntest";
- print $TESTERR "# $prefix got: " . _quote($result) .
+ print $out "# $prefix got: " . _quote($result) .
" ($$detail{context})\n";
$prefix = ' ' x (length($prefix) - 5);
my $expected_quoted = (defined $$detail{regex})
? 'qr{'.($$detail{regex}).'}' : _quote($expected);
- print $TESTERR "# $prefix Expected: $expected_quoted",
+ print $out "# $prefix Expected: $expected_quoted",
$diag ? " ($diag)" : (), "\n";
_diff_complain( $result, $expected, $detail, $prefix )
@@ -461,7 +462,7 @@ sub _complain {
}
if(defined $Program_Lines{ $$detail{file} }[ $$detail{line} ]) {
- print $TESTERR
+ print $out
"# $$detail{file} line $$detail{line} is: $Program_Lines{ $$detail{file} }[ $$detail{line} ]\n"
if $Program_Lines{ $$detail{file} }[ $$detail{line} ]
=~ m/[^\s\#\(\)\{\}\[\]\;]/; # Otherwise it's uninformative
--
Indomitable in retreat, invincible in advance, insufferable in victory
-- Churchill on Montgomery