Skip Menu |
 

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

Report information
The Basics
Id: 78758
Status: resolved
Priority: 0/
Queue: Test-HasVersion

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

Bug Information
Severity: Normal
Broken in: 0.012
Fixed in: 0.014



Subject: Fix for Test::Builder 1.5
Download (untitled) / with headers
text/plain 455b
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
Download tb.patch
text/x-diff 1.5k
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");
Download (untitled) / with headers
text/plain 375b
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
Subject: tb.patch
Download tb.patch
text/x-diff 1.5k
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 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.