tokuhirom / Test-Pretty

Other
20 stars 17 forks source link

Fix undefined sub name, clash with Test::Builder::Level #29

Open aanari opened 9 years ago

aanari commented 9 years ago

This pull request fixes the following erroneous warning output that occurs with more recent versions of Test::Builder, and allows Test::Pretty to work correctly:

$Test::Builder::Level is invalid. Testing library you are using is broken. : 4 at /Users/ali/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Test/Warnings.pm line 134. Test::Warnings::had_no_warnings("no (unexpected) warnings (via done_testing)") called at /Users/ali/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Test/Warnings.pm line 101 Test::Warnings::ANON(Test::Builder=HASH(0x7fd284000f90)) called at /Users/ali/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Test/More.pm line 220 Test::More::done_testing() called at t/14-cron-jobs/10-search-indexer.t line 46 Use of uninitialized value $sub in pattern match (m//) at /Users/ali/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Test/Pretty.pm line 275.

I tested the 0.31 tarball locally and everything works fine, and it passes all existing tests in the suite.

✓ no (unexpected) warnings (via done_testing)

lejeunerenard commented 9 years ago

@aanari can you specify what version of Test::Builder you are using? There has been several changes to Test::More recently and I want to make sure I'm testing against the same version. And can you give a brief example test that throws this warning?

preaction commented 8 years ago

I'm seeing this issue with Test::Builder 1.001014. The minimal test I need to see this is:

use Test::Builder;
my $tb = Test::Builder->new;
$tb->is_eq( 1, 1 );
$tb->done_testing;

It doesn't seem to happen with $tb->ok(...), so I'm guessing some of the internals got changed and the $Test::Builder::Level isn't quite what Test::Pretty expects. It seems is_eq is now implemented in terms of cmp_ok, so that might change what's going on.