Skip Menu |
 

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

Report information
The Basics
Id: 60906
Status: resolved
Priority: 0/
Queue: Test-Harness

People
Owner: Nobody in particular
Requestors: michaelgang [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 3.22
Fixed in: (no value)



Subject: when we make prints in .t file without newline then prove fails
Download (untitled) / with headers
text/plain 866b
Let's say i have the file a.t use strict; use Test::More; print scalar localtime time; ok(1,'kuku'); done_testing(); ~ Then the prove fails prove a.t a.t .. Failed 1/1 subtests Test Summary Report ------------------- a.t (Wstat: 0 Tests: 0 Failed: 0) Parse errors: Bad plan. You planned 1 tests but ran 0. Files=1, Tests=0, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.02 cusr 0.00 csys = 0.05 CPU) Result: FAIL If i add a print "\n"; it works use strict; use Test::More; print scalar localtime time; print "\n"; ok(1,'kuku'); done_testing(); ~ prove a.t a.t .. ok All tests successful. Files=1, Tests=1, 0 wallclock secs ( 0.04 usr 0.01 sys + 0.02 cusr 0.00 csys = 0.07 CPU) Result: PASS This means that any print without newline destroys the prove analysis. I also did not see that it is documented anywhere
Download (untitled) / with headers
text/plain 264b
That's inevitable I'm afraid - TAP is emitted on STDOUT so printing something without a newline hides the TAP. Any fix would at best be a workaround and would have to live in the domain of theTAP producer (Test::More) rather than theTAP consumer (Test::Harness)
Subject: Re: [rt.cpan.org #60906] when we make prints in .t file without newline then prove fails
Date: Tue, 31 Aug 2010 02:57:27 -0700
To: bug-Test-Harness [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
Download (untitled) / with headers
text/plain 661b
On 2010.8.31 12:54 AM, Andy Armstrong via RT wrote: Show quoted text
> That's inevitable I'm afraid - TAP is emitted on STDOUT so printing > something without a newline hides the TAP. > > Any fix would at best be a workaround and would have to live in the domain > of theTAP producer (Test::More) rather than theTAP consumer (Test::Harness)
If you control those prints, and they're for debugging and test instrumentation purposes, use note(). It will do the right thing. use strict; use Test::More; note scalar localtime; pass('kuku'); done_testing(); -- Reality is that which, when you stop believing in it, doesn't go away. -- Phillip K. Dick
From: michaelgang [...] gmail.com
Download (untitled) / with headers
text/plain 863b
Thanks for your prompt reply. Maybe it is obvious, but maybe it would be nice to document it somewhere that using print in .t files is not a good idea as prove would have problems to parse the output. On Tue Aug 31 05:57:38 2010, schwern@pobox.com wrote: Show quoted text
> On 2010.8.31 12:54 AM, Andy Armstrong via RT wrote:
> > That's inevitable I'm afraid - TAP is emitted on STDOUT so printing > > something without a newline hides the TAP. > > > > Any fix would at best be a workaround and would have to live in the
> domain
> > of theTAP producer (Test::More) rather than theTAP consumer
> (Test::Harness) > > If you control those prints, and they're for debugging and test > instrumentation purposes, use note(). It will do the right thing. > > use strict; > use Test::More; > > note scalar localtime; > pass('kuku'); > > done_testing(); > >


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.