Skip Menu |

This queue is for tickets about the Test-Output CPAN distribution.

Report information
The Basics
Id: 48691
Status: resolved
Priority: 0/
Queue: Test-Output

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.16
Fixed in: (no value)



Subject: Say and Print behave identically with stdout_is
Recently I have tried using 'Say' in stdout_is , and it appears to function identically to 'print', that is, the trailing \n say puts on never turns up in the test. use strict; use warnings; use 5.010; use Test::More; use Test::Output; my $expected = "Hello\nWorld\n"; stdout_is( sub { say "Hello"; say "World"; }, $expected, "say works" ); # not ok 1 - say works # Failed test 'say works' # at Stdout.t line 7. # STDOUT is: # HelloWorld # not: # Hello # World # # as expected stdout_is( sub { print "Hello\n"; print "World\n"; }, $expected, "print\\n works" ); # ok 2 - print\n works stdout_is( sub { say "Hello\nWorld" }, $expected, "say aggregate works" ); # not ok 3 - say aggregate works # Failed test 'say aggregate works' # at Stdout.t line 9. # STDOUT is: # Hello # World # not: # Hello # World # # as expected stdout_is( sub { print "Hello\nWorld\n" }, $expected, "print aggregate works" ); # ok 4 - print aggregate works
From: electr0sphere [...] yahoo.co.uk
I can confirm the same behaviour with say versus print. My environment is Debian Lenny, I am using Test::Output v0.16 which I installed from the CPAN source. I'm using Test::Output as a useful tool in testing CGI programs which I converted to "modulinos" [1]. I recently refactored them to use say 'foo' rather than print "foo\n". My test cases obviously fail because of this quirk of stdout_is. [1] http://www252.pair.com/comdog/mastering_perl/Chapters/18.modulinos.html
This is partly a problem with Perl and partly a problem with Test::Output. On the Test::Output side, Test::Output::Tie was not using $\. On the perl side, it appears that some versions of 5.10 don't set $\ as they should for a call to say. I will investigate further.
FWIW I just hit this bug. Here's the relevant perlbug. http://rt.perl.org/rt3/Public/Bug/Display.html?id=49264 This puts Test::Output users in the crappy position of getting different results on 5.10 and 5.12. If a test author works around it in 5.10 their test is going to fail in 5.12. If they write it correctly in 5.12 their test will fail in 5.10. Don't know what to tell you except put a warning in the docs and suggest that say() be tested with stdout_like { say $string } qr/^$string$/ if you're crossing the 5.10/5.12 boundry.
We no longer use a tie. David Golden updated this module to use Capture::Tiny, which should solve this problem since it doesn't fake IO.