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

Report information
The Basics
Id:
78758
Status:
resolved
Priority:
Low/Low

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



Subject: Fix for Test::Builder 1.5
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1343974149-25395-6"
Content-Length: 0
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 455
Hi, The attached patch fixes Test::HasVersion's tests for Test::Builder1.5. Test::Builder 1.5 adds a TAP version header to the TAP output, so the plan is no longer the first thing to come out. This could be hacked around in the test, but its safer to use Test::Builder::Tester which will better roll with TAP formatting changes. It also fixes the code so all_pm_version_ok() reports failure from the point where it's called, not inside HasVersion.pm.
Subject: tb.patch
MIME-Version: 1.0
Content-Type: text/x-diff; name="tb.patch"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline; filename="tb.patch"
Content-Transfer-Encoding: binary
Content-Length: 1589
diff --git a/HasVersion.pm b/HasVersion.pm index aefc19c..3a6ea58 100644 --- a/HasVersion.pm +++ b/HasVersion.pm @@ -167,6 +167,7 @@ the plan is left untouched. sub all_pm_version_ok { my @pm_files = all_pm_files(@_); + local $Test::Builder::Level = $Test::Builder::Level + 1; $Test->plan(tests => scalar @pm_files) unless $Test->has_plan; for (@pm_files) { pm_version_ok($_); diff --git a/t/04_all.ok.t b/t/04_all.ok.t index f009de7..93f0880 100755 --- a/t/04_all.ok.t +++ b/t/04_all.ok.t @@ -1,14 +1,8 @@ #!/usr/bin/perl -use Test::More tests => 4 + 3; - -use File::Spec; -my $null = File::Spec->devnull; - -ok(chdir "t/eg/", "cd t/eg"); -my @tap = `$^X -Mblib ../../t/97_has_version.t 2>$null`; -ok(scalar @tap, 't/97_has_version.t run ok'); -ok(chdir "../..", "cd ../.."); +use Test::Builder::Tester tests => 1; +use Test::More; +use Test::HasVersion; my @expected = ( 'A.pm' => 'ok', @@ -16,12 +10,18 @@ my @expected = ( 'lib/B/C.pm' => 'not ok', ); -like(shift @tap, qr/^1\.\.3/, 'good plan'); +test_out("1..3"); + +my $count = 1; +while(@expected) { + my $file = shift @expected; + my $want = shift @expected; + test_out("$want $count - $file has version"); + test_fail(+5) if $want eq 'not ok'; + $count++; +} -for (@tap) { - next if /^#/; - my $f = shift @expected; - my $ans = shift @expected; - like($_, qr/^$ans \d+ - $f/, $ans eq 'ok' ? "$f has version" : "$f has no version"); +chdir "t/eg/" or die "Can't chdir to t/eg"; +all_pm_version_ok(); -} \ No newline at end of file +test_test("all_pm_version_ok() including failures");
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: multipart/mixed; boundary="----------=_1343985976-21022-11"
Message-ID: <rt-3.8.HEAD-21022-1343985976-85.78758-0-0@rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 375
Sorry, that last patch had a mistake in it and wouldn't work with 0.98. This patch will work with 0.98, but it won't work with 1.5 until the next release (which will be 1.5.0_06) because it revealed a bug (or at least a lost accidental feature). But its an alpha so its safe to patch now. https://github.com/schwern/test-more/commit/00d4609f79fef0ad0db954ba9d9982026eb755e0
MIME-Version: 1.0
Subject: tb.patch
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: text/x-diff; name="tb.patch"
Content-Disposition: inline; filename="tb.patch"
Content-Transfer-Encoding: binary
Content-Length: 1568
diff --git a/HasVersion.pm b/HasVersion.pm index aefc19c..3a6ea58 100644 --- a/HasVersion.pm +++ b/HasVersion.pm @@ -167,6 +167,7 @@ the plan is left untouched. sub all_pm_version_ok { my @pm_files = all_pm_files(@_); + local $Test::Builder::Level = $Test::Builder::Level + 1; $Test->plan(tests => scalar @pm_files) unless $Test->has_plan; for (@pm_files) { pm_version_ok($_); diff --git a/t/04_all.ok.t b/t/04_all.ok.t index f009de7..b8be695 100755 --- a/t/04_all.ok.t +++ b/t/04_all.ok.t @@ -1,14 +1,8 @@ #!/usr/bin/perl -use Test::More tests => 4 + 3; - -use File::Spec; -my $null = File::Spec->devnull; - -ok(chdir "t/eg/", "cd t/eg"); -my @tap = `$^X -Mblib ../../t/97_has_version.t 2>$null`; -ok(scalar @tap, 't/97_has_version.t run ok'); -ok(chdir "../..", "cd ../.."); +use Test::Builder::Tester tests => 1; +use Test::More; +use Test::HasVersion; my @expected = ( 'A.pm' => 'ok', @@ -16,12 +10,16 @@ my @expected = ( 'lib/B/C.pm' => 'not ok', ); -like(shift @tap, qr/^1\.\.3/, 'good plan'); +my $count = 1; +while(@expected) { + my $file = shift @expected; + my $want = shift @expected; + test_out("$want $count - $file has version"); + test_fail(+5) if $want eq 'not ok'; + $count++; +} -for (@tap) { - next if /^#/; - my $f = shift @expected; - my $ans = shift @expected; - like($_, qr/^$ans \d+ - $f/, $ans eq 'ok' ? "$f has version" : "$f has no version"); +chdir "t/eg/" or die "Can't chdir to t/eg"; +all_pm_version_ok(); -} \ No newline at end of file +test_test("all_pm_version_ok() including failures");


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

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