Skip Menu |
 

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

Report information
The Basics
Id: 14981
Status: resolved
Priority: 0/
Queue: Test-Class

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

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

Attachments
testcases_with_hardcoded_stdout_stderr_checking.patch



Subject: Tests hard-coding expected error messages instead of using Test::Builder::Tester
Download (untitled) / with headers
text/plain 354b
Some changes in Test::More have resulted in a slight change in the STDERR format, that has broken some tests you hardcoded in. These tests should move to using the Test::Builder::Tester module, which has now been merged in the Test::More and will track future changes, if any. To reproduce the fails, upgrade Test::More to 0.62 and run the test suite.
From: Martín Ferrari <martin.ferrari [...] gmail.com>
Download (untitled) / with headers
text/plain 556b
On Sab. Oct. 08 04:34:32 2005, ADAMK wrote: Show quoted text
> Some changes in Test::More have resulted in a slight change in the > STDERR format, that has broken some tests you hardcoded in. > > These tests should move to using the Test::Builder::Tester module, > which has now been merged in the Test::More and will track future > changes, if any. > > To reproduce the fails, upgrade Test::More to 0.62 and run the test > suite.
It seems that those scripts were pretty broken. I had to rewrite a good part of them, but I think they are correct now. Patch is attached.
diff -Naur libtest-class-perl-0.11/t/die_before_plan.t libtest-class-perl-0.11-new/t/die_before_plan.t --- libtest-class-perl-0.11/t/die_before_plan.t 2005-02-19 16:32:33.000000000 -0300 +++ libtest-class-perl-0.11-new/t/die_before_plan.t 2006-04-16 05:13:58.474443044 -0300 @@ -3,10 +3,7 @@ use strict; use warnings; use Test; -use Fcntl; -use IO::File; -use Test::Builder; -use POSIX qw(_exit); +use Test::Builder::Tester tests => 1; package Object::Test; use base 'Test::Class'; @@ -23,29 +20,11 @@ package main; -my $io = IO::File->new_tmpfile or die "couldn't create tmp file ($!)\n"; -my $Test = Test::Builder->new; -$Test->output($io); -$Test->failure_output($io); -$ENV{TEST_VERBOSE}=0; -$ENV{HARNESS_ACTIVE}=0; -Object::Test->runtests; - -plan tests => 4; - -seek $io, SEEK_SET, 0; -my $SEP = $^O eq "MSWin32" ? '\\' : '/'; -while (my $actual = <$io>) { - chomp($actual); - my $expected=<DATA>; chomp($expected); - $expected =~ s!/!$SEP!gs; - ok($actual, $expected); -}; - -_exit(0); +#$ENV{TEST_VERBOSE}=0; +#$ENV{HARNESS_ACTIVE}=0; -__DATA__ -1..1 -not ok 1 - setup (for test method 'test') died (died before plan set) -# Failed test (t/die_before_plan.t at line 32) -ok 2 - test just here to get setup method run +test_out("not ok 1 - setup (for test method 'test') died (died before plan set)"); +test_fail(+2); +test_out("ok 2 - test just here to get setup method run"); +Object::Test->runtests; +test_test("die before plan"); diff -Naur libtest-class-perl-0.11/t/fail2.t libtest-class-perl-0.11-new/t/fail2.t --- libtest-class-perl-0.11/t/fail2.t 2005-02-19 16:32:33.000000000 -0300 +++ libtest-class-perl-0.11-new/t/fail2.t 2006-04-16 05:46:28.119145305 -0300 @@ -2,12 +2,8 @@ use strict; use warnings; -use Test; -use Test::Builder; -use Fcntl; -use IO::File; -use POSIX qw(_exit); - +use Test::More tests => 2; +use Test::Builder::Tester; package Object; sub new {return(undef)}; @@ -25,38 +21,18 @@ package main; +#$ENV{TEST_VERBOSE}=0; +#$ENV{HARNESS_ACTIVE}=0; -plan tests => 9; - -my $io = IO::File->new_tmpfile or die "couldn't create tmp file ($!)\n"; -my $Test = Test::Builder->new; -$Test->output($io); -$Test->failure_output($io); +test_out("not ok 1 - The object isa Object"); +test_out("not ok 2 - cannot create Objects"); +test_fail(-11); +test_err(qr/#\s+The object isn't defined\n/); +test_fail(-13); -$ENV{TEST_VERBOSE}=0; -$ENV{HARNESS_ACTIVE}=0; Object::Test->runtests; END { - $|=1; - seek $io, SEEK_SET, 0; - my $SEP = $^O eq "MSWin32" ? '\\' : '/'; - while (my $actual = <$io>) { - chomp($actual); - my $expected=<DATA>; chomp($expected); - $expected =~ s!/!$SEP!gs; - ok($actual, $expected); - }; - - ok($?, 3); - _exit(0); # need to stop Test::Builder's $? tweak -}; - -__DATA__ -1..3 -not ok 1 - The object isa Object -# Failed test (t/fail2.t at line 22) -# The object isn't defined -not ok 2 - cannot create Objects -# Failed test (t/fail2.t at line 22) -not ok 3 - cannot create Objects -# Failed test (t/fail2.t at line 22) + test_test("fail2"); + is($?, 2, "exit value okay"); + $?=0; +}
Thanks. Finally fixed in 0.12.


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.