Skip to content

Commit 58818a6

Browse files
exodistjkeenan
authored andcommitted
Update Test-Simple in blead
This updates to the latest Test-Simple. This fixes several small bugs including noisy STDERR in the test suite, and leaking TEMP files.
1 parent fbe0543 commit 58818a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+367
-264
lines changed

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,6 +2656,7 @@ cpan/Test-Simple/t/lib/Test/Simple/sample_tests/too_few.plx
26562656
cpan/Test-Simple/t/lib/Test/Simple/sample_tests/two_fail.plx
26572657
cpan/Test-Simple/t/lib/TieOut.pm
26582658
cpan/Test-Simple/t/regression/642_persistent_end.t
2659+
cpan/Test-Simple/t/regression/662-tbt-no-plan.t
26592660
cpan/Test-Simple/t/regression/no_name_in_subtest.t
26602661
cpan/Test-Simple/t/Test2/acceptance/try_it_done_testing.t
26612662
cpan/Test-Simple/t/Test2/acceptance/try_it_fork.t

cpan/Test-Simple/lib/Test/Builder.pm

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ use 5.006;
44
use strict;
55
use warnings;
66

7-
our $VERSION = '1.302015';
7+
our $VERSION = '1.302022';
88

99
BEGIN {
1010
if( $] < 5.008 ) {
1111
require Test::Builder::IO::Scalar;
1212
}
1313
}
1414

15-
use overload();
16-
1715
use Scalar::Util qw/blessed reftype weaken/;
1816

1917
use Test2::Util qw/USE_THREADS try get_tid/;
@@ -40,16 +38,7 @@ use Test::Builder::Formatter;
4038
use Test::Builder::TodoDiag;
4139

4240
our $Level = 1;
43-
our $Test = Test::Builder->new;
44-
45-
# Non-TB tools normally expect 0 added to the level. $Level is normally 1. So
46-
# we only want the level to change if $Level != 1.
47-
# TB->ctx compensates for this later.
48-
Test2::API::test2_add_callback_context_aquire(sub {$_[0]->{level} += $Level - 1});
49-
50-
Test2::API::test2_add_callback_exit(sub { $Test->_ending(@_) });
51-
52-
Test2::API::test2_ipc()->set_no_fatal(1) if USE_THREADS;
41+
our $Test = $ENV{TB_NO_EARLY_INIT} ? undef : Test::Builder->new;
5342

5443
sub _add_ts_hooks {
5544
my $self = shift;
@@ -102,6 +91,15 @@ sub new {
10291
my $ctx = context();
10392
$Test = $class->create(singleton => 1);
10493
$ctx->release;
94+
95+
# Non-TB tools normally expect 0 added to the level. $Level is normally 1. So
96+
# we only want the level to change if $Level != 1.
97+
# TB->ctx compensates for this later.
98+
Test2::API::test2_add_callback_context_aquire(sub { $_[0]->{level} += $Level - 1 });
99+
100+
Test2::API::test2_add_callback_exit(sub { $Test->_ending(@_) });
101+
102+
Test2::API::test2_ipc()->set_no_fatal(1) if USE_THREADS;
105103
}
106104
return $Test;
107105
}
@@ -304,7 +302,7 @@ sub subtest {
304302
($err, $child_error) = ($@, $?);
305303

306304
# They might have done 'BEGIN { skip_all => "whatever" }'
307-
if (!$ok && $err =~ m/Label not found for "last T2_SUBTEST_WRAPPER"/) {
305+
if (!$ok && $err =~ m/Label not found for "last T2_SUBTEST_WRAPPER"/ || (blessed($err) && blessed($err) eq 'Test::Builder::Exception')) {
308306
$ok = undef;
309307
$err = undef;
310308
}
@@ -486,6 +484,12 @@ sub no_plan {
486484

487485
my $ctx = $self->ctx;
488486

487+
if (defined $ctx->hub->plan) {
488+
warn "Plan already set, no_plan() is a no-op, this will change to a hard failure in the future.";
489+
$ctx->release;
490+
return;
491+
}
492+
489493
$ctx->alert("no_plan takes no arguments") if $arg;
490494

491495
$ctx->hub->plan('NO PLAN');
@@ -685,6 +689,10 @@ sub _unoverload {
685689

686690
return unless ref $$thing;
687691
return unless blessed($$thing) || scalar $self->_try(sub{ $$thing->isa('UNIVERSAL') });
692+
{
693+
local ($!, $@);
694+
require overload;
695+
}
688696
my $string_meth = overload::Method( $$thing, $type ) || return;
689697
$$thing = $$thing->$string_meth();
690698
}
@@ -1731,9 +1739,9 @@ Ok, so there can be more than one Test::Builder object and this is how
17311739
you get it. You might use this instead of C<new()> if you're testing
17321740
a Test::Builder based module, but otherwise you probably want C<new>.
17331741
1734-
B<NOTE>: the implementation is not complete. C<level>, for example, is
1735-
still shared amongst B<all> Test::Builder objects, even ones created using
1736-
this method. Also, the method name may change in the future.
1742+
B<NOTE>: the implementation is not complete. C<level>, for example, is still
1743+
shared by B<all> Test::Builder objects, even ones created using this method.
1744+
Also, the method name may change in the future.
17371745
17381746
=item B<subtest>
17391747
@@ -1780,19 +1788,6 @@ will print the appropriate headers and take the appropriate actions.
17801788
17811789
If you call C<plan()>, don't call any of the other methods below.
17821790
1783-
If a child calls "skip_all" in the plan, a C<Test::Builder::Exception> is
1784-
thrown. Trap this error, call C<finalize()> and don't run any more tests on
1785-
the child.
1786-
1787-
my $child = $Test->child('some child');
1788-
eval { $child->plan( $condition ? ( skip_all => $reason ) : ( tests => 3 ) ) };
1789-
if ( eval { $@->isa('Test::Builder::Exception') } ) {
1790-
$child->finalize;
1791-
return;
1792-
}
1793-
# run your tests
1794-
1795-
17961791
=item B<expected_tests>
17971792
17981793
my $max = $Test->expected_tests;
@@ -2020,7 +2015,7 @@ Takes a quoted regular expression produced by C<qr//>, or a string
20202015
representing a regular expression.
20212016
20222017
Returns a Perl value which may be used instead of the corresponding
2023-
regular expression, or C<undef> if its argument is not recognised.
2018+
regular expression, or C<undef> if its argument is not recognized.
20242019
20252020
For example, a version of C<like()>, sans the useful diagnostic messages,
20262021
could be written as:
@@ -2440,9 +2435,9 @@ If you fail more than 254 tests, it will be reported as 254.
24402435
24412436
=head1 THREADS
24422437
2443-
In perl 5.8.1 and later, Test::Builder is thread-safe. The test
2444-
number is shared amongst all threads. This means if one thread sets
2445-
the test number using C<current_test()> they will all be effected.
2438+
In perl 5.8.1 and later, Test::Builder is thread-safe. The test number is
2439+
shared by all threads. This means if one thread sets the test number using
2440+
C<current_test()> they will all be effected.
24462441
24472442
While versions earlier than 5.8.1 had threads they contain too many
24482443
bugs to support.

cpan/Test-Simple/lib/Test/Builder/Formatter.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package Test::Builder::Formatter;
22
use strict;
33
use warnings;
44

5-
our $VERSION = '1.302015';
5+
our $VERSION = '1.302022';
66

7-
use base 'Test2::Formatter::TAP';
7+
BEGIN { require Test2::Formatter::TAP; our @ISA = qw(Test2::Formatter::TAP) }
88

99
use Test2::Util::HashBase qw/no_header no_diag/;
1010

cpan/Test-Simple/lib/Test/Builder/Module.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package Test::Builder::Module;
22

33
use strict;
44

5-
use Test::Builder 1.00;
5+
use Test::Builder;
66

77
require Exporter;
88
our @ISA = qw(Exporter);
99

10-
our $VERSION = '1.302015';
10+
our $VERSION = '1.302022';
1111

1212

1313
=head1 NAME
@@ -89,7 +89,8 @@ sub import {
8989

9090
$test->plan(@_);
9191

92-
$class->export_to_level( 1, $class, @imports );
92+
local $Exporter::ExportLevel = $Exporter::ExportLevel + 1;
93+
$class->Exporter::import(@imports);
9394
}
9495

9596
sub _strip_imports {

cpan/Test-Simple/lib/Test/Builder/Tester.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package Test::Builder::Tester;
22

33
use strict;
4-
our $VERSION = '1.302015';
4+
our $VERSION = '1.302022';
55

6-
use Test::Builder 0.99;
6+
use Test::Builder;
77
use Symbol;
88
use Carp;
99

cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Test::Builder::Tester::Color;
22

33
use strict;
4-
our $VERSION = '1.302015';
4+
our $VERSION = '1.302022';
55

66
require Test::Builder::Tester;
77

cpan/Test-Simple/lib/Test/Builder/TodoDiag.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package Test::Builder::TodoDiag;
22
use strict;
33
use warnings;
44

5-
our $VERSION = '1.302015';
5+
our $VERSION = '1.302022';
66

7-
use base 'Test2::Event::Diag';
7+
BEGIN { require Test2::Event::Diag; our @ISA = qw(Test2::Event::Diag) }
88

99
sub diagnostics { 0 }
1010

cpan/Test-Simple/lib/Test/More.pm

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ sub _carp {
1717
return warn @_, " at $file line $line\n";
1818
}
1919

20-
our $VERSION = '1.302015';
20+
our $VERSION = '1.302022';
2121

22-
use Test::Builder::Module 0.99;
22+
use Test::Builder::Module;
2323
our @ISA = qw(Test::Builder::Module);
2424
our @EXPORT = qw(ok use_ok require_ok
2525
is isnt like unlike is_deeply
@@ -175,12 +175,22 @@ sub import_extra {
175175

176176
my @other = ();
177177
my $idx = 0;
178+
my $import;
178179
while( $idx <= $#{$list} ) {
179180
my $item = $list->[$idx];
180181

181182
if( defined $item and $item eq 'no_diag' ) {
182183
$class->builder->no_diag(1);
183184
}
185+
elsif( defined $item and $item eq 'import' ) {
186+
if ($import) {
187+
push @$import, @{$list->[ ++$idx ]};
188+
}
189+
else {
190+
$import = $list->[ ++$idx ];
191+
push @other, $item, $import;
192+
}
193+
}
184194
else {
185195
push @other, $item;
186196
}
@@ -190,6 +200,18 @@ sub import_extra {
190200

191201
@$list = @other;
192202

203+
if ($class eq __PACKAGE__ && (!$import || grep $_ eq '$TODO', @$import)) {
204+
my $to = $class->builder->exported_to;
205+
no strict 'refs';
206+
*{"$to\::TODO"} = \our $TODO;
207+
if ($import) {
208+
@$import = grep $_ ne '$TODO', @$import;
209+
}
210+
else {
211+
push @$list, import => [grep $_ ne '$TODO', @EXPORT];
212+
}
213+
}
214+
193215
return;
194216
}
195217

cpan/Test-Simple/lib/Test/Simple.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use 5.006;
44

55
use strict;
66

7-
our $VERSION = '1.302015';
7+
our $VERSION = '1.302022';
88

9-
use Test::Builder::Module 0.99;
9+
use Test::Builder::Module;
1010
our @ISA = qw(Test::Builder::Module);
1111
our @EXPORT = qw(ok);
1212

cpan/Test-Simple/lib/Test/Tester.pm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require Exporter;
1818

1919
use vars qw( @ISA @EXPORT );
2020

21-
our $VERSION = '1.302015';
21+
our $VERSION = '1.302022';
2222

2323
@EXPORT = qw( run_tests check_tests check_test cmp_results show_space );
2424
@ISA = qw( Exporter );
@@ -40,7 +40,7 @@ sub show_space
4040
my $colour = '';
4141
my $reset = '';
4242

43-
if (my $want_colour = $ENV{TESTTESTERCOLOUR} || $ENV{TESTTESTERCOLOUR})
43+
if (my $want_colour = $ENV{TESTTESTERCOLOUR} || $ENV{TESTTESTERCOLOR})
4444
{
4545
if (eval "require Term::ANSIColor")
4646
{
@@ -447,7 +447,7 @@ diagnostics output B<after> the test result is declared.
447447
448448
Note that Test::Builder ensures that any diagnostics end in a \n and
449449
it in earlier versions of Test::Tester it was essential that you have
450-
the final \n in your expected diagnostics. From version 0.10 onwards,
450+
the final \n in your expected diagnostics. From version 0.10 onward,
451451
Test::Tester will add the \n if you forgot it. It will not add a \n if
452452
you are expecting no diagnostics. See below for help tracking down
453453
hard to find space and tab related problems.
@@ -496,7 +496,7 @@ are scratching your head trying to work out why Test::Tester is saying that
496496
your diagnostics are wrong when they look perfectly right then the answer is
497497
probably whitespace. From version 0.10 on, Test::Tester surrounds the
498498
expected and got diag values with single quotes to make it easier to spot
499-
trailing whitesapce. So in this example
499+
trailing whitespace. So in this example
500500
501501
# Got diag (5 bytes):
502502
# 'abcd '
@@ -514,7 +514,7 @@ switch Test::Tester into a mode whereby all "tricky" characters are shown as
514514
\{xx}. Tricky characters are those with ASCII code less than 33 or higher
515515
than 126. This makes the output more difficult to read but much easier to
516516
find subtle differences between strings. To turn on this mode either call
517-
show_space() in your test script or set the TESTTESTERSPACE environment
517+
C<show_space()> in your test script or set the C<TESTTESTERSPACE> environment
518518
variable to be a true value. The example above would then look like
519519
520520
# Got diag (5 bytes):
@@ -525,13 +525,13 @@ variable to be a true value. The example above would then look like
525525
=head1 COLOUR
526526
527527
If you prefer to use colour as a means of finding tricky whitespace
528-
characters then you can set the TESTTESTCOLOUR environment variable to a
528+
characters then you can set the C<TESTTESTCOLOUR> environment variable to a
529529
comma separated pair of colours, the first for the foreground, the second
530530
for the background. For example "white,red" will print white text on a red
531531
background. This requires the Term::ANSIColor module. You can specify any
532532
colour that would be acceptable to the Term::ANSIColor::color function.
533533
534-
If you spell colour differently, that's no problem. The TESTTESTERCOLOR
534+
If you spell colour differently, that's no problem. The C<TESTTESTERCOLOR>
535535
variable also works (if both are set then the British spelling wins out).
536536
537537
=head1 EXPORTED FUNCTIONS

cpan/Test-Simple/lib/Test/Tester/Capture.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use strict;
22

33
package Test::Tester::Capture;
44

5-
our $VERSION = '1.302015';
5+
our $VERSION = '1.302022';
66

77

88
use Test::Builder;

cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use strict;
33

44
package Test::Tester::CaptureRunner;
55

6-
our $VERSION = '1.302015';
6+
our $VERSION = '1.302022';
77

88

99
use Test::Tester::Capture;

cpan/Test-Simple/lib/Test/Tester/Delegate.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use warnings;
33

44
package Test::Tester::Delegate;
55

6-
our $VERSION = '1.302015';
6+
our $VERSION = '1.302022';
77

88

99
use vars '$AUTOLOAD';

cpan/Test-Simple/lib/Test/use/ok.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package Test::use::ok;
22
use 5.005;
33

4-
our $VERSION = '1.302015';
4+
our $VERSION = '1.302022';
55

66

77
__END__

0 commit comments

Comments
 (0)