Skip Menu |

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

Report information
The Basics
Id: 65249
Status: open
Priority: 0/
Queue: Test-Able

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

Bug Information
Severity: Normal
Broken in: 0.10
Fixed in: (no value)



Subject: Can not grab at the internals of Test::Builder
Test::Able::Role::Meta::Class uses the internals of Test::Builder in several places. This is not safe. Those internals will and have changed. Here are their equivalent, documented methods: $b->{Curr_Test} -> $b->current_test $b->{No_Plan} -> $b->has_plan eq 'no_plan' $b->{Expected_Tests} -> $b->expected_tests You cannot update $b->{Expected_Tests} directly and expect it to continue to work. I would suggest you track the build up of your plan separately and call $b->done_testing($your_plan) at the end.
From: ppisar [...] redhat.com
Dne So 29.led.2011 17:04:47, MSCHWERN napsal(a): Show quoted text
> Test::Able::Role::Meta::Class uses the internals of Test::Builder in > several places. This is not safe. Those internals will and have changed. > > Here are their equivalent, documented methods: > > $b->{Curr_Test} -> $b->current_test > $b->{No_Plan} -> $b->has_plan eq 'no_plan' > $b->{Expected_Tests} -> $b->expected_tests > > You cannot update $b->{Expected_Tests} directly and expect it to > continue to work. I would suggest you track the build up of your plan > separately and call $b->done_testing($your_plan) at the end.
And the tests fail with Test-Simple-1.302019 now: t/methods.t ..... ok Use of uninitialized value $tests_before in subtraction (-) at /home/test/fedora/perl-Test-Able/Test-Able-0.11/blib/lib/Test/Able/Role/Meta/Class.pm line 371. Use of uninitialized value in subtraction (-) at /home/test/fedora/perl-Test-Able/Test-Able-0.11/blib/lib/Test/Able/Role/Meta/Class.pm line 371. [...] bad plan (0) at t/plans.t line 99. END failed--call queue aborted. # Looks like your test exited with 22 just after 66. You have loaded versions of test modules known to have problems with Test2. This could explain some test failures. * Module 'Test::Able' is known to be broken in version 0.11 and below, newer versions have not been tested. You have: 0.11 t/plans.t ....... Dubious, test returned 22 (wstat 5632, 0x1600) All 66 subtests passed
From: ppisar [...] redhat.com
Dne So 29.led.2011 17:04:47, MSCHWERN napsal(a): Show quoted text
> Test::Able::Role::Meta::Class uses the internals of Test::Builder in > several places. This is not safe. Those internals will and have changed. >
Please look at the attached patch. It makes tests passing again.
Subject: Test-Able-0.11-Adapt-to-Test-Simple-1.302019.patch
From 23d457c1528c44c4fb1aca34cccc5f18086fc5c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> Date: Mon, 23 May 2016 18:16:24 +0200 Subject: [PATCH] Adapt to Test-Simple-1.302019 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch removes touching internals of the Test::Builder. More code could be removed probably. Also I removed the trailing END test in t/plans.t because number of expected tests is not a global variable anymore and thus it's not accessible out of the test scope. I do not understand how t/cookbook.t gets plan defined to no_plan, but if I kept setting plan to no_plan in the _build_runner_plan's else branch, Test::Builder would complain about multiple setting to no_plan. Actually if all the branches after the "return $plan if $self->dry_run;" are removed, the tests will pass. Maybe current Test::Builder is smart enough to count the expected tests properly. CPAN RT#65249 Signed-off-by: Petr Písař <ppisar@redhat.com> --- lib/Test/Able/Role/Meta/Class.pm | 20 +++++++++----------- t/plans.t | 5 ----- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/lib/Test/Able/Role/Meta/Class.pm b/lib/Test/Able/Role/Meta/Class.pm index ab31e92..8056dc6 100644 --- a/lib/Test/Able/Role/Meta/Class.pm +++ b/lib/Test/Able/Role/Meta/Class.pm @@ -304,6 +304,7 @@ sub run_tests { } # Finalize planning for this run. + $self->builder->{able_Finalized} = 1; $self->clear_runner_plan; $self->runner_plan; $self->clear_last_runner_plan; @@ -348,7 +349,7 @@ sub run_methods { } unless ( $setup_exception_count || $self->dry_run ) { - my $tests_before = $self->builder->{Curr_Test}; + my $tests_before = $self->builder->current_test; eval { $self->current_test_object->$method_name; }; if ( my $exception = $@ ) { @@ -368,7 +369,7 @@ sub run_methods { } if ( $self->on_method_plan_fail && $method->plan =~ /^\d+$/ ) { - my $tests_diff = $self->builder->{Curr_Test} - $tests_before; + my $tests_diff = $self->builder->current_test - $tests_before; if ( $tests_diff != $method->plan ) { my $msg = "Method $method_name planned " . $method->plan . " tests but ran $tests_diff."; @@ -550,24 +551,22 @@ sub _build_runner_plan { return $plan if $self->dry_run; - $self->builder->no_plan unless $self->builder->has_plan; - - # Update Test::Builder. - if ( $self->builder->{No_Plan} || $self->builder->{was_No_Plan} ) { + if ( !defined $self->builder->has_plan || $self->builder->has_plan eq 'no_plan' || $self->builder->{was_No_Plan} ) { if ( $plan =~ /^\d+$/ ) { if ( $self->has_last_runner_plan ) { my $last = $self->last_runner_plan; my $plan_diff = $plan - ( $last eq 'no_plan' ? 0 : $last ); - $self->builder->{Expected_Tests} += $plan_diff; + $self->builder->{able_Plan} += $plan_diff; + if ($self->builder->{able_Finalized} and !defined $self->builder->has_plan) { + $self->builder->plan(tests => $self->builder->{able_Plan}); + } } else { - $self->builder->{Expected_Tests} += $plan; + $self->builder->{able_Plan} += $plan; } - $self->builder->{No_Plan} = 0; $self->builder->{was_No_Plan} = 1; $self->last_runner_plan( $plan ); } - else { $self->builder->{No_Plan} = 1; } } return $plan; @@ -587,7 +586,6 @@ sub _hack_test_builder { my $builder = shift; if ( $builder->{was_No_Plan} && $self->runner_plan =~ /\d+/ ) { - $builder->expected_tests( $self->builder->{Expected_Tests} ); $builder->no_header( 1 ); } diff --git a/t/plans.t b/t/plans.t index 38cc9f3..4b48de1 100644 --- a/t/plans.t +++ b/t/plans.t @@ -94,8 +94,3 @@ sub set_plan_on_no_plan_methods { return; } -sub END { - my $tb = Test::Builder->new; - die 'bad plan (' . $tb->expected_tests . ')' - unless $tb->expected_tests == 66; -} -- 2.5.5
From: ppisar [...] redhat.com
Dne Po 23.Květen.2016 12:29:29, ppisar napsal(a): Show quoted text
> Dne So 29.led.2011 17:04:47, MSCHWERN napsal(a):
> > Test::Able::Role::Meta::Class uses the internals of Test::Builder in > > several places. This is not safe. Those internals will and have changed. > >
> Please look at the attached patch. It makes tests passing again.
It broke Test-Able-Runner tests. This new patch keeps the defaulting to no_plan to make Test-Able-Runner happy.
Subject: Test-Able-0.11-Adapt-to-Test-Simple-1.302019.patch
From 2d6f07d759103700030e5b8d619e7d3bfd4d0b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> Date: Mon, 23 May 2016 18:16:24 +0200 Subject: [PATCH] Adapt to Test-Simple-1.302019 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch removes touching internals of the Test::Builder. More code could be removed probably. Also I removed the trailing END test in t/plans.t because number of expected tests is not a global variable anymore and thus it's not accessible out of the test scope. I do not understand how t/cookbook.t gets plan defined to no_plan, but if I kept setting plan to no_plan unconditionally in the _build_runner_plan's else branch, Test::Builder would complain about multiple setting to no_plan. Actually if all the branches after the "return $plan if $self->dry_run;" are removed, the tests will pass. Maybe current Test::Builder is smart enough to count the expected tests properly. CPAN RT#65249 Signed-off-by: Petr Písař <ppisar@redhat.com> --- lib/Test/Able/Role/Meta/Class.pm | 25 ++++++++++++++----------- t/plans.t | 5 ----- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/Test/Able/Role/Meta/Class.pm b/lib/Test/Able/Role/Meta/Class.pm index ab31e92..1f42c4b 100644 --- a/lib/Test/Able/Role/Meta/Class.pm +++ b/lib/Test/Able/Role/Meta/Class.pm @@ -304,6 +304,7 @@ sub run_tests { } # Finalize planning for this run. + $self->builder->{able_Finalized} = 1; $self->clear_runner_plan; $self->runner_plan; $self->clear_last_runner_plan; @@ -348,7 +349,7 @@ sub run_methods { } unless ( $setup_exception_count || $self->dry_run ) { - my $tests_before = $self->builder->{Curr_Test}; + my $tests_before = $self->builder->current_test; eval { $self->current_test_object->$method_name; }; if ( my $exception = $@ ) { @@ -368,7 +369,7 @@ sub run_methods { } if ( $self->on_method_plan_fail && $method->plan =~ /^\d+$/ ) { - my $tests_diff = $self->builder->{Curr_Test} - $tests_before; + my $tests_diff = $self->builder->current_test - $tests_before; if ( $tests_diff != $method->plan ) { my $msg = "Method $method_name planned " . $method->plan . " tests but ran $tests_diff."; @@ -550,24 +551,27 @@ sub _build_runner_plan { return $plan if $self->dry_run; - $self->builder->no_plan unless $self->builder->has_plan; - - # Update Test::Builder. - if ( $self->builder->{No_Plan} || $self->builder->{was_No_Plan} ) { + if ( !defined $self->builder->has_plan || $self->builder->has_plan eq 'no_plan' || $self->builder->{was_No_Plan} ) { if ( $plan =~ /^\d+$/ ) { if ( $self->has_last_runner_plan ) { my $last = $self->last_runner_plan; my $plan_diff = $plan - ( $last eq 'no_plan' ? 0 : $last ); - $self->builder->{Expected_Tests} += $plan_diff; + $self->builder->{able_Plan} += $plan_diff; + if ($self->builder->{able_Finalized} and !defined $self->builder->has_plan) { + $self->builder->plan(tests => $self->builder->{able_Plan}); + } } else { - $self->builder->{Expected_Tests} += $plan; + $self->builder->{able_Plan} += $plan; } - $self->builder->{No_Plan} = 0; $self->builder->{was_No_Plan} = 1; $self->last_runner_plan( $plan ); } - else { $self->builder->{No_Plan} = 1; } + else { + if ($self->builder->{able_Finalized} and !defined $self->builder->has_plan) { + $self->builder->no_plan; + } + } } return $plan; @@ -587,7 +591,6 @@ sub _hack_test_builder { my $builder = shift; if ( $builder->{was_No_Plan} && $self->runner_plan =~ /\d+/ ) { - $builder->expected_tests( $self->builder->{Expected_Tests} ); $builder->no_header( 1 ); } diff --git a/t/plans.t b/t/plans.t index 38cc9f3..4b48de1 100644 --- a/t/plans.t +++ b/t/plans.t @@ -94,8 +94,3 @@ sub set_plan_on_no_plan_methods { return; } -sub END { - my $tb = Test::Builder->new; - die 'bad plan (' . $tb->expected_tests . ')' - unless $tb->expected_tests == 66; -} -- 2.5.5