|
|
bcbce1c |
From 2d6f07d759103700030e5b8d619e7d3bfd4d0b52 Mon Sep 17 00:00:00 2001
|
|
|
bcbce1c |
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
|
bcbce1c |
Date: Mon, 23 May 2016 18:16:24 +0200
|
|
|
bcbce1c |
Subject: [PATCH] Adapt to Test-Simple-1.302019
|
|
|
bcbce1c |
MIME-Version: 1.0
|
|
|
bcbce1c |
Content-Type: text/plain; charset=UTF-8
|
|
|
bcbce1c |
Content-Transfer-Encoding: 8bit
|
|
|
bcbce1c |
|
|
|
bcbce1c |
This patch removes touching internals of the Test::Builder. More code
|
|
|
bcbce1c |
could be removed probably.
|
|
|
bcbce1c |
|
|
|
bcbce1c |
Also I removed the trailing END test in t/plans.t because number of
|
|
|
bcbce1c |
expected tests is not a global variable anymore and thus it's not
|
|
|
bcbce1c |
accessible out of the test scope.
|
|
|
bcbce1c |
|
|
|
bcbce1c |
I do not understand how t/cookbook.t gets plan defined to no_plan, but
|
|
|
bcbce1c |
if I kept setting plan to no_plan unconditionally in the
|
|
|
bcbce1c |
_build_runner_plan's else branch, Test::Builder would complain about
|
|
|
bcbce1c |
multiple setting to no_plan.
|
|
|
bcbce1c |
|
|
|
bcbce1c |
Actually if all the branches after the "return $plan if $self->dry_run;"
|
|
|
bcbce1c |
are removed, the tests will pass. Maybe current Test::Builder is smart
|
|
|
bcbce1c |
enough to count the expected tests properly.
|
|
|
bcbce1c |
|
|
|
bcbce1c |
CPAN RT#65249
|
|
|
bcbce1c |
|
|
|
bcbce1c |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
bcbce1c |
---
|
|
|
bcbce1c |
lib/Test/Able/Role/Meta/Class.pm | 25 ++++++++++++++-----------
|
|
|
bcbce1c |
t/plans.t | 5 -----
|
|
|
bcbce1c |
2 files changed, 14 insertions(+), 16 deletions(-)
|
|
|
bcbce1c |
|
|
|
bcbce1c |
diff --git a/lib/Test/Able/Role/Meta/Class.pm b/lib/Test/Able/Role/Meta/Class.pm
|
|
|
bcbce1c |
index ab31e92..1f42c4b 100644
|
|
|
bcbce1c |
--- a/lib/Test/Able/Role/Meta/Class.pm
|
|
|
bcbce1c |
+++ b/lib/Test/Able/Role/Meta/Class.pm
|
|
|
bcbce1c |
@@ -304,6 +304,7 @@ sub run_tests {
|
|
|
bcbce1c |
}
|
|
|
bcbce1c |
|
|
|
bcbce1c |
# Finalize planning for this run.
|
|
|
bcbce1c |
+ $self->builder->{able_Finalized} = 1;
|
|
|
bcbce1c |
$self->clear_runner_plan;
|
|
|
bcbce1c |
$self->runner_plan;
|
|
|
bcbce1c |
$self->clear_last_runner_plan;
|
|
|
bcbce1c |
@@ -348,7 +349,7 @@ sub run_methods {
|
|
|
bcbce1c |
}
|
|
|
bcbce1c |
|
|
|
bcbce1c |
unless ( $setup_exception_count || $self->dry_run ) {
|
|
|
bcbce1c |
- my $tests_before = $self->builder->{Curr_Test};
|
|
|
bcbce1c |
+ my $tests_before = $self->builder->current_test;
|
|
|
bcbce1c |
|
|
|
bcbce1c |
eval { $self->current_test_object->$method_name; };
|
|
|
bcbce1c |
if ( my $exception = $@ ) {
|
|
|
bcbce1c |
@@ -368,7 +369,7 @@ sub run_methods {
|
|
|
bcbce1c |
}
|
|
|
bcbce1c |
|
|
|
bcbce1c |
if ( $self->on_method_plan_fail && $method->plan =~ /^\d+$/ ) {
|
|
|
bcbce1c |
- my $tests_diff = $self->builder->{Curr_Test} - $tests_before;
|
|
|
bcbce1c |
+ my $tests_diff = $self->builder->current_test - $tests_before;
|
|
|
bcbce1c |
if ( $tests_diff != $method->plan ) {
|
|
|
bcbce1c |
my $msg = "Method $method_name planned " . $method->plan
|
|
|
bcbce1c |
. " tests but ran $tests_diff.";
|
|
|
bcbce1c |
@@ -550,24 +551,27 @@ sub _build_runner_plan {
|
|
|
bcbce1c |
|
|
|
bcbce1c |
return $plan if $self->dry_run;
|
|
|
bcbce1c |
|
|
|
bcbce1c |
- $self->builder->no_plan unless $self->builder->has_plan;
|
|
|
bcbce1c |
-
|
|
|
bcbce1c |
- # Update Test::Builder.
|
|
|
bcbce1c |
- if ( $self->builder->{No_Plan} || $self->builder->{was_No_Plan} ) {
|
|
|
bcbce1c |
+ if ( !defined $self->builder->has_plan || $self->builder->has_plan eq 'no_plan' || $self->builder->{was_No_Plan} ) {
|
|
|
bcbce1c |
if ( $plan =~ /^\d+$/ ) {
|
|
|
bcbce1c |
if ( $self->has_last_runner_plan ) {
|
|
|
bcbce1c |
my $last = $self->last_runner_plan;
|
|
|
bcbce1c |
my $plan_diff = $plan - ( $last eq 'no_plan' ? 0 : $last );
|
|
|
bcbce1c |
- $self->builder->{Expected_Tests} += $plan_diff;
|
|
|
bcbce1c |
+ $self->builder->{able_Plan} += $plan_diff;
|
|
|
bcbce1c |
+ if ($self->builder->{able_Finalized} and !defined $self->builder->has_plan) {
|
|
|
bcbce1c |
+ $self->builder->plan(tests => $self->builder->{able_Plan});
|
|
|
bcbce1c |
+ }
|
|
|
bcbce1c |
}
|
|
|
bcbce1c |
else {
|
|
|
bcbce1c |
- $self->builder->{Expected_Tests} += $plan;
|
|
|
bcbce1c |
+ $self->builder->{able_Plan} += $plan;
|
|
|
bcbce1c |
}
|
|
|
bcbce1c |
- $self->builder->{No_Plan} = 0;
|
|
|
bcbce1c |
$self->builder->{was_No_Plan} = 1;
|
|
|
bcbce1c |
$self->last_runner_plan( $plan );
|
|
|
bcbce1c |
}
|
|
|
bcbce1c |
- else { $self->builder->{No_Plan} = 1; }
|
|
|
bcbce1c |
+ else {
|
|
|
bcbce1c |
+ if ($self->builder->{able_Finalized} and !defined $self->builder->has_plan) {
|
|
|
bcbce1c |
+ $self->builder->no_plan;
|
|
|
bcbce1c |
+ }
|
|
|
bcbce1c |
+ }
|
|
|
bcbce1c |
}
|
|
|
bcbce1c |
|
|
|
bcbce1c |
return $plan;
|
|
|
bcbce1c |
@@ -587,7 +591,6 @@ sub _hack_test_builder {
|
|
|
bcbce1c |
my $builder = shift;
|
|
|
bcbce1c |
|
|
|
bcbce1c |
if ( $builder->{was_No_Plan} && $self->runner_plan =~ /\d+/ ) {
|
|
|
bcbce1c |
- $builder->expected_tests( $self->builder->{Expected_Tests} );
|
|
|
bcbce1c |
$builder->no_header( 1 );
|
|
|
bcbce1c |
}
|
|
|
bcbce1c |
|
|
|
bcbce1c |
diff --git a/t/plans.t b/t/plans.t
|
|
|
bcbce1c |
index 38cc9f3..4b48de1 100644
|
|
|
bcbce1c |
--- a/t/plans.t
|
|
|
bcbce1c |
+++ b/t/plans.t
|
|
|
bcbce1c |
@@ -94,8 +94,3 @@ sub set_plan_on_no_plan_methods {
|
|
|
bcbce1c |
return;
|
|
|
bcbce1c |
}
|
|
|
bcbce1c |
|
|
|
bcbce1c |
-sub END {
|
|
|
bcbce1c |
- my $tb = Test::Builder->new;
|
|
|
bcbce1c |
- die 'bad plan (' . $tb->expected_tests . ')'
|
|
|
bcbce1c |
- unless $tb->expected_tests == 66;
|
|
|
bcbce1c |
-}
|
|
|
bcbce1c |
--
|
|
|
bcbce1c |
2.5.5
|
|
|
bcbce1c |
|