Package: libtest-class-perl Version: 0.11-1 Followup-For: Bug #358745 tags 358745 +patch thanks
Hi, After studying what was happening I found that this bug was also reported in CPAN 6 months ago, and it's still open (http://rt.cpan.org/Public/Bug/Display.html?id=14981). There is a tip for solving the problem: using Test::Builder::Tester for replacing hardcoded strings. In many t/*.t files, T::B::T is already being used. So, I rewrote part of the two offending test files, and I think they are correct. They work perfectly now. I have already sent this patch to upstream, but since they doesn't seem very active, I think it would be good if we patch it now. I include the specific patch for the test files, and also a patch for the package, which includes the other patch and the modifications con debian/rules and debian/control for using dpatch. NOTE: in the patch I replaced the libtest-builder-tester-perl dependency with perl-modules > 5.8.8, since the former are now included in the latter. -- Martín Ferrari
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; +}
diff -Naur libtest-class-perl-0.11-new/debian/control libtest-class-perl-0.11-newdebian/debian/control --- libtest-class-perl-0.11-new/debian/control 2006-04-15 01:30:27.000000000 -0300 +++ libtest-class-perl-0.11-newdebian/debian/control 2006-04-16 06:57:13.819123404 -0300 @@ -2,12 +2,12 @@ Section: perl Priority: optional Maintainer: Jay Bonci <[EMAIL PROTECTED]> -Build-Depends-Indep: debhelper (>> 4.0), perl (>= 5.6.0-16), libtest-builder-tester-perl, libtest-differences-perl, libtest-exception-perl, libio-string-perl, libmodule-build-perl, libdevel-symdump-perl +Build-Depends-Indep: debhelper (>> 4.0), perl (>= 5.6.0-16), perl-modules (>= 5.8.8), libtest-differences-perl, libtest-exception-perl, libio-string-perl, libmodule-build-perl, libdevel-symdump-perl, dpatch Standards-Version: 3.6.2.1 Package: libtest-class-perl Architecture: all -Depends: ${perl:Depends}, libtest-builder-tester-perl, libtest-differences-perl, libtest-exception-perl, libio-string-perl, libdevel-symdump-perl +Depends: ${perl:Depends}, perl-modules (>= 5.8.8), libtest-differences-perl, libtest-exception-perl, libio-string-perl, libdevel-symdump-perl Suggests: libdate-ical-perl Description: easily create perl test classes in an xUnit style Test::Class from CPAN provides a simple way of creating classes diff -Naur libtest-class-perl-0.11-new/debian/patches/00list libtest-class-perl-0.11-newdebian/debian/patches/00list --- libtest-class-perl-0.11-new/debian/patches/00list 1969-12-31 21:00:00.000000000 -0300 +++ libtest-class-perl-0.11-newdebian/debian/patches/00list 2006-04-16 06:47:52.926220393 -0300 @@ -0,0 +1 @@ +testcases_hardcoding diff -Naur libtest-class-perl-0.11-new/debian/patches/testcases_hardcoding.dpatch libtest-class-perl-0.11-newdebian/debian/patches/testcases_hardcoding.dpatch --- libtest-class-perl-0.11-new/debian/patches/testcases_hardcoding.dpatch 1969-12-31 21:00:00.000000000 -0300 +++ libtest-class-perl-0.11-newdebian/debian/patches/testcases_hardcoding.dpatch 2006-04-16 06:49:46.840111343 -0300 @@ -0,0 +1,128 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## testcases_hardcoding.patch.dpatch by Martin Ferrari <[EMAIL PROTECTED]> +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Fix for the two testcases which failed because of a hardcoded +## DP: stdout/stderr checking + [EMAIL PROTECTED]@ +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; ++} diff -Naur libtest-class-perl-0.11-new/debian/rules libtest-class-perl-0.11-newdebian/debian/rules --- libtest-class-perl-0.11-new/debian/rules 2006-04-15 01:30:27.000000000 -0300 +++ libtest-class-perl-0.11-newdebian/debian/rules 2006-04-16 06:59:43.401026949 -0300 @@ -7,15 +7,17 @@ # This is the debhelper compatibility version to use. #export DH_COMPAT=4 +include /usr/share/dpatch/dpatch.make PACKAGE=`pwd | sed -e "s/.*\/\\(.*\\)-.*/\\1/"` SHAREDIR=$(CURDIR)/debian/$(PACKAGE)/usr/share/$(PACKAGE) -build: +build: patch dh_testdir # Add here commands to compile the package. perl Build.PL installdirs=vendor -clean: +clean: clean-patched unpatch +clean-patched: dh_testdir dh_testroot diff -Naur libtest-class-perl-0.11-new/t/die_before_plan.t libtest-class-perl-0.11-newdebian/t/die_before_plan.t --- libtest-class-perl-0.11-new/t/die_before_plan.t 2006-04-16 05:13:58.000000000 -0300 +++ libtest-class-perl-0.11-newdebian/t/die_before_plan.t 2006-04-16 06:58:08.961871555 -0300 @@ -3,7 +3,10 @@ use strict; use warnings; use Test; -use Test::Builder::Tester tests => 1; +use Fcntl; +use IO::File; +use Test::Builder; +use POSIX qw(_exit); package Object::Test; use base 'Test::Class'; @@ -20,11 +23,29 @@ package main; -#$ENV{TEST_VERBOSE}=0; -#$ENV{HARNESS_ACTIVE}=0; - -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"); +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; -test_test("die before plan"); + +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); + +__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 diff -Naur libtest-class-perl-0.11-new/t/fail2.t libtest-class-perl-0.11-newdebian/t/fail2.t --- libtest-class-perl-0.11-new/t/fail2.t 2006-04-16 05:46:28.000000000 -0300 +++ libtest-class-perl-0.11-newdebian/t/fail2.t 2006-04-16 06:58:08.966870716 -0300 @@ -2,8 +2,12 @@ use strict; use warnings; -use Test::More tests => 2; -use Test::Builder::Tester; +use Test; +use Test::Builder; +use Fcntl; +use IO::File; +use POSIX qw(_exit); + package Object; sub new {return(undef)}; @@ -21,18 +25,38 @@ package main; -#$ENV{TEST_VERBOSE}=0; -#$ENV{HARNESS_ACTIVE}=0; -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); +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); +$ENV{TEST_VERBOSE}=0; +$ENV{HARNESS_ACTIVE}=0; Object::Test->runtests; END { - test_test("fail2"); - is($?, 2, "exit value okay"); - $?=0; -} + $|=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)