summaryrefslogtreecommitdiff
path: root/cpan
diff options
context:
space:
mode:
authorChad Granum <chad.granum@dreamhost.com>2014-11-23 20:57:26 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-26 12:41:46 -0800
commit67fc0004fa1c09062059ab924c7ea75cb33d9e2e (patch)
tree888c227899259a345f9a9a800f3ce44431d46b9c /cpan
parent1e4e7e8099cdbe735e6f5c4b9a97c01e0e3f10f4 (diff)
downloadperl-67fc0004fa1c09062059ab924c7ea75cb33d9e2e.tar.gz
Update Test-Simple to alpha 079
Diffstat (limited to 'cpan')
-rw-r--r--cpan/Test-Simple/lib/Test/Builder.pm5
-rw-r--r--cpan/Test-Simple/lib/Test/Builder/Module.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Builder/Tester.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/More.pm41
-rw-r--r--cpan/Test-Simple/lib/Test/More/Tools.pm58
-rw-r--r--cpan/Test-Simple/lib/Test/Simple.pm4
-rw-r--r--cpan/Test-Simple/lib/Test/Stream.pm58
-rw-r--r--cpan/Test-Simple/lib/Test/Stream/Subtest.pm188
-rw-r--r--cpan/Test-Simple/lib/Test/Tester.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/use/ok.pm2
-rw-r--r--cpan/Test-Simple/lib/ok.pm2
-rw-r--r--cpan/Test-Simple/t/Behavior/skip_all_in_subtest.t12
-rw-r--r--cpan/Test-Simple/t/Behavior/skip_all_in_subtest1.load (renamed from cpan/Test-Simple/t/Behavior/skip_all_in_subtest.load)0
-rw-r--r--cpan/Test-Simple/t/Behavior/skip_all_in_subtest2.load12
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/basic.t4
16 files changed, 310 insertions, 84 deletions
diff --git a/cpan/Test-Simple/lib/Test/Builder.pm b/cpan/Test-Simple/lib/Test/Builder.pm
index 2144c93456..2955e07c8d 100644
--- a/cpan/Test-Simple/lib/Test/Builder.pm
+++ b/cpan/Test-Simple/lib/Test/Builder.pm
@@ -4,7 +4,7 @@ use 5.008001;
use strict;
use warnings;
-our $VERSION = '1.301001_078';
+our $VERSION = '1.301001_079';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
@@ -141,7 +141,8 @@ sub _copy {
sub subtest {
my $self = shift;
my $ctx = $self->ctx();
- return tmt->subtest(@_);
+ require Test::Stream::Subtest;
+ return Test::Stream::Subtest::subtest(@_);
}
sub child {
diff --git a/cpan/Test-Simple/lib/Test/Builder/Module.pm b/cpan/Test-Simple/lib/Test/Builder/Module.pm
index 0ff9ce1a9d..d0b3003426 100644
--- a/cpan/Test-Simple/lib/Test/Builder/Module.pm
+++ b/cpan/Test-Simple/lib/Test/Builder/Module.pm
@@ -8,7 +8,7 @@ use Test::Builder 0.99;
require Exporter;
our @ISA = qw(Exporter);
-our $VERSION = '1.301001_078';
+our $VERSION = '1.301001_079';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
diff --git a/cpan/Test-Simple/lib/Test/Builder/Tester.pm b/cpan/Test-Simple/lib/Test/Builder/Tester.pm
index 7b2e9b46e1..f6711a77bd 100644
--- a/cpan/Test-Simple/lib/Test/Builder/Tester.pm
+++ b/cpan/Test-Simple/lib/Test/Builder/Tester.pm
@@ -1,7 +1,7 @@
package Test::Builder::Tester;
use strict;
-our $VERSION = '1.301001_078';
+our $VERSION = '1.301001_079';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Stream 1.301001 '-internal';
diff --git a/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm b/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm
index dfdb50d262..98d690bf41 100644
--- a/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm
+++ b/cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm
@@ -1,7 +1,7 @@
package Test::Builder::Tester::Color;
use strict;
-our $VERSION = '1.301001_078';
+our $VERSION = '1.301001_079';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Stream 1.301001 '-internal';
diff --git a/cpan/Test-Simple/lib/Test/More.pm b/cpan/Test-Simple/lib/Test/More.pm
index 585fd8a48a..b186cc965b 100644
--- a/cpan/Test-Simple/lib/Test/More.pm
+++ b/cpan/Test-Simple/lib/Test/More.pm
@@ -4,12 +4,13 @@ use 5.008001;
use strict;
use warnings;
-our $VERSION = '1.301001_078';
+our $VERSION = '1.301001_079';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Stream 1.301001 '-internal';
use Test::Stream::Util qw/protect try spoof/;
use Test::Stream::Toolset;
+use Test::Stream::Subtest qw/subtest/;
use Test::Stream::Carp qw/croak carp/;
use Scalar::Util qw/blessed/;
@@ -239,11 +240,6 @@ sub fail (;$) {
return $ctx->ok(0, @_);
}
-sub subtest {
- my $ctx = context();
- return tmt->subtest(@_);
-}
-
sub explain {
my $ctx = context();
tmt->explain(@_);
@@ -1048,6 +1044,39 @@ subtests are equivalent:
done_testing();
};
+B<NOTE on using skip_all in a BEGIN inside a subtest.>
+
+Sometimes you want to run a file as a subtest:
+
+ subtest foo => sub { do 'foo.pl' };
+
+where foo.pl;
+
+ use Test::More skip_all => "won't work";
+
+This will work fine, but will issue a warning. The issue is that the normal
+flow control method will now work inside a BEGIN block. The C<use Test::More>
+statement is run in a BEGIN block. As a result an exception is thrown instead
+of the normal flow control. In most cases this works fine.
+
+A case like this however will have issues:
+
+ subtest foo => sub {
+ do 'foo.pl'; # Will issue a skip_all
+
+ # You would expect the subtest to stop, but the 'do' captures the
+ # exception, as a result the following statement does execute.
+
+ ok(0, "blah");
+ };
+
+You can work around this by cheking the return from C<do>, along with C<$@>, or you can alter foo.pl so that it does this:
+
+ use Test::More;
+ plan skip_all => 'broken';
+
+When the plan is issues outside of the BEGIN block it works just fine.
+
=item B<pass>
=item B<fail>
diff --git a/cpan/Test-Simple/lib/Test/More/Tools.pm b/cpan/Test-Simple/lib/Test/More/Tools.pm
index 98027cc977..554b3d90b9 100644
--- a/cpan/Test-Simple/lib/Test/More/Tools.pm
+++ b/cpan/Test-Simple/lib/Test/More/Tools.pm
@@ -322,64 +322,6 @@ sub _cmp_diag {
DIAGNOSTIC
}
-sub subtest {
- my ($class, $name, $code, @args) = @_;
-
- my $ctx = context();
-
- $ctx->throw("subtest()'s second argument must be a code ref")
- unless $code && 'CODE' eq reftype($code);
-
- $ctx->child('push', $name);
- $ctx->clear;
- my $todo = $ctx->hide_todo;
-
- my $pid = $$;
-
- my ($succ, $err) = try {
- {
- no warnings 'once';
- local $Test::Builder::Level = 1;
- $code->(@args);
- }
-
- $ctx->set;
- my $stream = $ctx->stream;
- $ctx->done_testing unless $stream->plan || $stream->ended;
-
- require Test::Stream::ExitMagic;
- {
- local $? = 0;
- Test::Stream::ExitMagic->new->do_magic($stream, $ctx->snapshot);
- }
- };
-
- if ($$ != $pid && !$ctx->stream->_use_fork) {
- warn <<" EOT";
-Subtest finished with a new PID ($$ vs $pid) while forking support was turned off!
-This is almost certainly not what you wanted. Did you fork and forget to exit?
- EOT
-
- # Did the forked process try to exit via die?
- die $err unless $succ;
- }
-
- # If a subtest forked, then threw an exception, we need to propogate that right away.
- die $err unless $succ || $$ == $pid || $err->isa('Test::Stream::Event');
-
- $ctx->set;
- $ctx->restore_todo($todo);
- # This sends the subtest event
- my $st = $ctx->child('pop', $name);
-
- unless ($succ) {
- die $err unless blessed($err) && $err->isa('Test::Stream::Event');
- $ctx->bail($err->reason) if $err->isa('Test::Stream::Event::Bail');
- }
-
- return $st->bool;
-}
-
1;
__END__
diff --git a/cpan/Test-Simple/lib/Test/Simple.pm b/cpan/Test-Simple/lib/Test/Simple.pm
index 61cc2c3c93..bf140dcc4e 100644
--- a/cpan/Test-Simple/lib/Test/Simple.pm
+++ b/cpan/Test-Simple/lib/Test/Simple.pm
@@ -5,10 +5,10 @@ use 5.008001;
use strict;
use warnings;
-our $VERSION = '1.301001_078';
+our $VERSION = '1.301001_079';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
-use Test::Stream 1.301001_078 '-internal';
+use Test::Stream 1.301001_079 '-internal';
use Test::Stream::Toolset;
use Test::Stream::Exporter;
diff --git a/cpan/Test-Simple/lib/Test/Stream.pm b/cpan/Test-Simple/lib/Test/Stream.pm
index 2011c5b767..2b47ed779e 100644
--- a/cpan/Test-Simple/lib/Test/Stream.pm
+++ b/cpan/Test-Simple/lib/Test/Stream.pm
@@ -2,7 +2,7 @@ package Test::Stream;
use strict;
use warnings;
-our $VERSION = '1.301001_078';
+our $VERSION = '1.301001_079';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Stream::Context qw/context/;
@@ -577,6 +577,18 @@ sub _render_tap {
}
}
+sub _scan_for_begin {
+ my ($stop_at) = @_;
+ my $level = 2;
+
+ while (my @call = caller($level++)) {
+ return 1 if $call[3] =~ m/::BEGIN$/;
+ return 0 if $call[3] eq $stop_at;
+ }
+
+ return undef;
+}
+
sub _finalize_event {
my ($self, $e, $cache) = @_;
@@ -587,7 +599,27 @@ sub _finalize_event {
$self->[SUBTEST_EXCEPTION]->[-1] = $e if $e->in_subtest;
- die $e if $e->in_subtest || !$self->[EXIT_ON_DISRUPTION];
+ if ($e->in_subtest) {
+ my $begin = _scan_for_begin('Test::Stream::Subtest::subtest');
+
+ if ($begin) {
+ warn "SKIP_ALL in subtest via 'BEGIN' or 'use', using exception for flow control\n";
+ die $e;
+ }
+ elsif(defined $begin) {
+ no warnings 'exiting';
+ eval { last TEST_STREAM_SUBTEST };
+ warn "SKIP_ALL in subtest flow control error: $@";
+ warn "Falling back to using an exception.\n";
+ die $e;
+ }
+ else {
+ warn "SKIP_ALL in subtest could not find flow-control label, using exception for flow control\n";
+ die $e;
+ }
+ }
+
+ die $e unless $self->[EXIT_ON_DISRUPTION];
exit 0;
}
elsif (!$cache->{do_tap} && $e->isa('Test::Stream::Event::Bail')) {
@@ -596,7 +628,27 @@ sub _finalize_event {
$self->[SUBTEST_EXCEPTION]->[-1] = $e if $e->in_subtest;
- die $e if $e->in_subtest || !$self->[EXIT_ON_DISRUPTION];
+ if ($e->in_subtest) {
+ my $begin = _scan_for_begin('Test::Stream::Subtest::subtest');
+
+ if ($begin) {
+ warn "BAILOUT in subtest via 'BEGIN' or 'use', using exception for flow control.\n";
+ die $e;
+ }
+ elsif(defined $begin) {
+ no warnings 'exiting';
+ eval { last TEST_STREAM_SUBTEST };
+ warn "BAILOUT in subtest flow control error: $@";
+ warn "Falling back to using an exception.\n";
+ die $e;
+ }
+ else {
+ warn "BAILOUT in subtest could not find flow-control label, using exception for flow control.\n";
+ die $e;
+ }
+ }
+
+ die $e unless $self->[EXIT_ON_DISRUPTION];
exit 255;
}
}
diff --git a/cpan/Test-Simple/lib/Test/Stream/Subtest.pm b/cpan/Test-Simple/lib/Test/Stream/Subtest.pm
new file mode 100644
index 0000000000..4540758c2e
--- /dev/null
+++ b/cpan/Test-Simple/lib/Test/Stream/Subtest.pm
@@ -0,0 +1,188 @@
+package Test::Stream::Subtest;
+use strict;
+use warnings;
+
+use Test::Stream::Exporter;
+default_exports qw/subtest/;
+Test::Stream::Exporter->cleanup;
+
+use Test::Stream::Context qw/context/;
+use Scalar::Util qw/reftype blessed/;
+use Test::Stream::Util qw/try/;
+
+sub subtest {
+ my ($name, $code, @args) = @_;
+
+ my $ctx = context();
+
+ $ctx->throw("subtest()'s second argument must be a code ref")
+ unless $code && 'CODE' eq reftype($code);
+
+ $ctx->child('push', $name);
+ $ctx->clear;
+ my $todo = $ctx->hide_todo;
+
+ my $pid = $$;
+
+ my ($succ, $err) = try {
+ my $early_return = 1;
+
+ TEST_STREAM_SUBTEST: {
+ no warnings 'once';
+ local $Test::Builder::Level = 1;
+ $code->(@args);
+ $early_return = 0;
+ }
+
+ die $ctx->stream->subtest_exception->[-1] if $early_return;
+
+ $ctx->set;
+ my $stream = $ctx->stream;
+ $ctx->done_testing unless $stream->plan || $stream->ended;
+
+ require Test::Stream::ExitMagic;
+ {
+ local $? = 0;
+ Test::Stream::ExitMagic->new->do_magic($stream, $ctx->snapshot);
+ }
+ };
+
+ if ($$ != $pid && !$ctx->stream->_use_fork) {
+ warn <<" EOT";
+Subtest finished with a new PID ($$ vs $pid) while forking support was turned off!
+This is almost certainly not what you wanted. Did you fork and forget to exit?
+ EOT
+
+ # Did the forked process try to exit via die?
+ die $err unless $succ;
+ }
+
+ # If a subtest forked, then threw an exception, we need to propogate that right away.
+ die $err unless $succ || $$ == $pid || $err->isa('Test::Stream::Event');
+
+ $ctx->set;
+ $ctx->restore_todo($todo);
+ # This sends the subtest event
+ my $st = $ctx->child('pop', $name);
+
+ unless ($succ) {
+ die $err unless blessed($err) && $err->isa('Test::Stream::Event');
+ $ctx->bail($err->reason) if $err->isa('Test::Stream::Event::Bail');
+ }
+
+ return $st->bool;
+}
+
+1;
+
+__END__
+
+=head1 Name
+
+Test::Stream::Subtest - Encapsulate subtest start, run, and finish.
+
+=head1 Synopsys
+
+ use Test::Stream::Subtest;
+
+ subtest $name => sub { ... };
+
+=encoding utf8
+
+=head1 SOURCE
+
+The source code repository for Test::More can be found at
+F<http://github.com/Test-More/test-more/>.
+
+=head1 MAINTAINER
+
+=over 4
+
+=item Chad Granum E<lt>exodist@cpan.orgE<gt>
+
+=back
+
+=head1 AUTHORS
+
+The following people have all contributed to the Test-More dist (sorted using
+VIM's sort function).
+
+=over 4
+
+=item Chad Granum E<lt>exodist@cpan.orgE<gt>
+
+=item Fergal Daly E<lt>fergal@esatclear.ie>E<gt>
+
+=item Mark Fowler E<lt>mark@twoshortplanks.comE<gt>
+
+=item Michael G Schwern E<lt>schwern@pobox.comE<gt>
+
+=item 唐鳳
+
+=back
+
+=head1 COPYRIGHT
+
+There has been a lot of code migration between modules,
+here are all the original copyrights together:
+
+=over 4
+
+=item Test::Stream
+
+=item Test::Stream::Tester
+
+Copyright 2014 Chad Granum E<lt>exodist7@gmail.comE<gt>.
+
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+See F<http://www.perl.com/perl/misc/Artistic.html>
+
+=item Test::Simple
+
+=item Test::More
+
+=item Test::Builder
+
+Originally authored by Michael G Schwern E<lt>schwern@pobox.comE<gt> with much
+inspiration from Joshua Pritikin's Test module and lots of help from Barrie
+Slaymaker, Tony Bowden, blackstar.co.uk, chromatic, Fergal Daly and the perl-qa
+gang.
+
+Idea by Tony Bowden and Paul Johnson, code by Michael G Schwern
+E<lt>schwern@pobox.comE<gt>, wardrobe by Calvin Klein.
+
+Copyright 2001-2008 by Michael G Schwern E<lt>schwern@pobox.comE<gt>.
+
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+See F<http://www.perl.com/perl/misc/Artistic.html>
+
+=item Test::use::ok
+
+To the extent possible under law, 唐鳳 has waived all copyright and related
+or neighboring rights to L<Test-use-ok>.
+
+This work is published from Taiwan.
+
+L<http://creativecommons.org/publicdomain/zero/1.0>
+
+=item Test::Tester
+
+This module is copyright 2005 Fergal Daly <fergal@esatclear.ie>, some parts
+are based on other people's work.
+
+Under the same license as Perl itself
+
+See http://www.perl.com/perl/misc/Artistic.html
+
+=item Test::Builder::Tester
+
+Copyright Mark Fowler E<lt>mark@twoshortplanks.comE<gt> 2002, 2004.
+
+This program is free software; you can redistribute it
+and/or modify it under the same terms as Perl itself.
+
+=back
diff --git a/cpan/Test-Simple/lib/Test/Tester.pm b/cpan/Test-Simple/lib/Test/Tester.pm
index 5fd8b11311..2f36c8f9b8 100644
--- a/cpan/Test-Simple/lib/Test/Tester.pm
+++ b/cpan/Test-Simple/lib/Test/Tester.pm
@@ -16,7 +16,7 @@ require Exporter;
use vars qw( @ISA @EXPORT $VERSION );
-our $VERSION = '1.301001_078';
+our $VERSION = '1.301001_079';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
@EXPORT = qw( run_tests check_tests check_test cmp_results show_space );
diff --git a/cpan/Test-Simple/lib/Test/use/ok.pm b/cpan/Test-Simple/lib/Test/use/ok.pm
index 72e94372ab..a07c0a7f9e 100644
--- a/cpan/Test-Simple/lib/Test/use/ok.pm
+++ b/cpan/Test-Simple/lib/Test/use/ok.pm
@@ -3,7 +3,7 @@ use strict;
use warnings;
use 5.005;
-our $VERSION = '1.301001_078';
+our $VERSION = '1.301001_079';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Stream 1.301001 '-internal';
diff --git a/cpan/Test-Simple/lib/ok.pm b/cpan/Test-Simple/lib/ok.pm
index b83c7ec528..088ec7e478 100644
--- a/cpan/Test-Simple/lib/ok.pm
+++ b/cpan/Test-Simple/lib/ok.pm
@@ -6,7 +6,7 @@ use Test::Stream 1.301001 '-internal';
use Test::More 1.301001 ();
use Test::Stream::Carp qw/croak/;
-our $VERSION = '1.301001_078';
+our $VERSION = '1.301001_079';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
sub import {
diff --git a/cpan/Test-Simple/t/Behavior/skip_all_in_subtest.t b/cpan/Test-Simple/t/Behavior/skip_all_in_subtest.t
index c66901a5a8..d4b12ce7db 100644
--- a/cpan/Test-Simple/t/Behavior/skip_all_in_subtest.t
+++ b/cpan/Test-Simple/t/Behavior/skip_all_in_subtest.t
@@ -5,12 +5,16 @@ use warnings;
use Test::More;
-subtest my_subtest => sub {
+subtest my_subtest1 => sub {
my $file = __FILE__;
- $file =~ s/\.t$/.load/;
+ $file =~ s/\.t$/1.load/;
+ do $file;
+};
+
+subtest my_subtest2 => sub {
+ my $file = __FILE__;
+ $file =~ s/\.t$/2.load/;
do $file;
- note "Got: $@";
- fail($@);
};
done_testing;
diff --git a/cpan/Test-Simple/t/Behavior/skip_all_in_subtest.load b/cpan/Test-Simple/t/Behavior/skip_all_in_subtest1.load
index 241ce14963..241ce14963 100644
--- a/cpan/Test-Simple/t/Behavior/skip_all_in_subtest.load
+++ b/cpan/Test-Simple/t/Behavior/skip_all_in_subtest1.load
diff --git a/cpan/Test-Simple/t/Behavior/skip_all_in_subtest2.load b/cpan/Test-Simple/t/Behavior/skip_all_in_subtest2.load
new file mode 100644
index 0000000000..6ce306a6de
--- /dev/null
+++ b/cpan/Test-Simple/t/Behavior/skip_all_in_subtest2.load
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Carp qw/confess/;
+
+use Test::More;
+
+plan skip_all => "Cause I feel like it";
+
+confess "Should not see this!";
diff --git a/cpan/Test-Simple/t/Legacy/subtest/basic.t b/cpan/Test-Simple/t/Legacy/subtest/basic.t
index 964b60d6bf..5a0166d5db 100644
--- a/cpan/Test-Simple/t/Legacy/subtest/basic.t
+++ b/cpan/Test-Simple/t/Legacy/subtest/basic.t
@@ -15,7 +15,7 @@ use warnings;
use Test::Builder::NoOutput;
-use Test::More tests => 18;
+use Test::More tests => 16;
# Formatting may change if we're running under Test::Harness.
$ENV{HARNESS_ACTIVE} = 0;
@@ -168,8 +168,6 @@ END
{
my $child = $tb->child('skippy says he loves you');
eval { $child->plan( skip_all => 'cuz I said so' ) };
- ok my $error = $@, 'A child which does a "skip_all" should throw an exception';
- isa_ok $error, 'Test::Stream::Event', '... and the exception it throws';
}
subtest 'skip all', sub {
plan skip_all => 'subtest with skip_all';