1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
From 940e2f641870a85d44b8c53e505c8ebccb39f2b1 Mon Sep 17 00:00:00 2001
From: Chad Granum <exodist7@gmail.com>
Date: Wed, 1 Feb 2017 19:33:57 -0800
Subject: Reset inside subtest maintains parent
When TB->reset is called from within a subtest it should maintain the
link to the parent, this link is necessary for unwinding the TB-stack.
Fixes #757
[backported to Debian Perl 5.26 by Niko Tyni <ntyni@debian.org>]
Origin: backport, https://github.com/Test-More/test-more/commit/68775db7eef1a7e30dc03abf8feabcf3e32301d4
Bug: https://github.com/Test-More/test-more/issues/757
Bug-Debian: https://bugs.debian.org/865894
Patch-Name: fixes/test-builder-reset.diff
---
cpan/Test-Simple/lib/Test/Builder.pm | 4 +++-
cpan/Test-Simple/t/regression/757-reset_in_subtest.t | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 cpan/Test-Simple/t/regression/757-reset_in_subtest.t
diff --git a/cpan/Test-Simple/lib/Test/Builder.pm b/cpan/Test-Simple/lib/Test/Builder.pm
index 052e2793b9..851a5f6669 100644
--- a/cpan/Test-Simple/lib/Test/Builder.pm
+++ b/cpan/Test-Simple/lib/Test/Builder.pm
@@ -143,7 +143,8 @@ sub parent {
my $chub = $self->{Hub} || $ctx->hub;
$ctx->release;
- my $parent = $chub->meta(__PACKAGE__, {})->{parent};
+ my $meta = $chub->meta(__PACKAGE__, {});
+ my $parent = $meta->{parent};
return undef unless $parent;
@@ -388,6 +389,7 @@ sub reset { ## no critic (Subroutines::ProhibitBuiltinHomonyms)
Done_Testing => undef,
Skip_All => 0,
Test_Results => [],
+ parent => $meta->{parent},
);
$self->{Exported_To} = undef;
diff --git a/cpan/Test-Simple/t/regression/757-reset_in_subtest.t b/cpan/Test-Simple/t/regression/757-reset_in_subtest.t
new file mode 100644
index 0000000000..846a34d835
--- /dev/null
+++ b/cpan/Test-Simple/t/regression/757-reset_in_subtest.t
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+subtest 'subtest' => sub {
+ Test::Builder->new->reset;
+ ok 1;
+};
+
+subtest 'subtest' => sub {
+ Test::Builder->new->reset;
+ subtest 'subtest' => sub {
+ Test::Builder->new->reset;
+ ok 1;
+ };
+ ok 1;
+};
+
+done_testing;
|