diff options
author | Chad Granum <chad.granum@dreamhost.com> | 2014-11-22 11:58:05 -0800 |
---|---|---|
committer | James E Keenan <jkeenan@cpan.org> | 2014-11-22 16:18:39 -0500 |
commit | 136323e46f5f3fabc977dadf1206c0686aa4c585 (patch) | |
tree | 61596e6cc7aa6813b2669f1f5d719d6725f83c52 /cpan/Test-Simple | |
parent | a500b25a5344f706749468868700f4c5e48ff813 (diff) | |
download | perl-136323e46f5f3fabc977dadf1206c0686aa4c585.tar.gz |
Update Test-Simple to alpha 076
For: RT #123277
Diffstat (limited to 'cpan/Test-Simple')
-rw-r--r-- | cpan/Test-Simple/lib/Test/Builder.pm | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/Test/Builder/Module.pm | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/Test/Builder/Tester.pm | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/Test/More.pm | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/Test/More/Tools.pm | 15 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/Test/Simple.pm | 4 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/Test/Stream.pm | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/Test/Stream/Context.pm | 13 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/Test/Stream/IOSets.pm | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/Test/Tester.pm | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/Test/use/ok.pm | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/lib/ok.pm | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/t/Legacy/fork_die.t | 79 |
14 files changed, 115 insertions, 16 deletions
diff --git a/cpan/Test-Simple/lib/Test/Builder.pm b/cpan/Test-Simple/lib/Test/Builder.pm index 1a28d72fa1..aa9a417187 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_075'; +our $VERSION = '1.301001_076'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) diff --git a/cpan/Test-Simple/lib/Test/Builder/Module.pm b/cpan/Test-Simple/lib/Test/Builder/Module.pm index 2ad2454a97..79340ed18d 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_075'; +our $VERSION = '1.301001_076'; $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 28c0113af7..dfdfc5e0e0 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_075'; +our $VERSION = '1.301001_076'; $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 e8dfa857c2..6498c6acb3 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_075'; +our $VERSION = '1.301001_076'; $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 fcbf4c597f..d1b7e65caa 100644 --- a/cpan/Test-Simple/lib/Test/More.pm +++ b/cpan/Test-Simple/lib/Test/More.pm @@ -4,7 +4,7 @@ use 5.008001; use strict; use warnings; -our $VERSION = '1.301001_075'; +our $VERSION = '1.301001_076'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) use Test::Stream 1.301001 '-internal'; diff --git a/cpan/Test-Simple/lib/Test/More/Tools.pm b/cpan/Test-Simple/lib/Test/More/Tools.pm index 7357f35610..98027cc977 100644 --- a/cpan/Test-Simple/lib/Test/More/Tools.pm +++ b/cpan/Test-Simple/lib/Test/More/Tools.pm @@ -334,6 +334,8 @@ sub subtest { $ctx->clear; my $todo = $ctx->hide_todo; + my $pid = $$; + my ($succ, $err) = try { { no warnings 'once'; @@ -352,6 +354,19 @@ sub subtest { } }; + 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 diff --git a/cpan/Test-Simple/lib/Test/Simple.pm b/cpan/Test-Simple/lib/Test/Simple.pm index c5e6808041..297c4905d4 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_075'; +our $VERSION = '1.301001_076'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) -use Test::Stream 1.301001_075 '-internal'; +use Test::Stream 1.301001_076 '-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 789544dbef..6decda349e 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_075'; +our $VERSION = '1.301001_076'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) use Test::Stream::Context qw/context/; diff --git a/cpan/Test-Simple/lib/Test/Stream/Context.pm b/cpan/Test-Simple/lib/Test/Stream/Context.pm index 5b17d42350..51b89e26ca 100644 --- a/cpan/Test-Simple/lib/Test/Stream/Context.pm +++ b/cpan/Test-Simple/lib/Test/Stream/Context.pm @@ -164,10 +164,15 @@ sub _find_context { my $level = 2 + $add + $tb; my ($package, $file, $line, $subname) = caller($level); - return unless $package; - - while ($package eq 'Test::Builder') { - ($package, $file, $line, $subname) = caller(++$level); + if ($package) { + while ($package eq 'Test::Builder') { + ($package, $file, $line, $subname) = caller(++$level); + } + } + else { + while (!$package) { + ($package, $file, $line, $subname) = caller(--$level); + } } return unless $package; diff --git a/cpan/Test-Simple/lib/Test/Stream/IOSets.pm b/cpan/Test-Simple/lib/Test/Stream/IOSets.pm index ae862776fd..e2352efec5 100644 --- a/cpan/Test-Simple/lib/Test/Stream/IOSets.pm +++ b/cpan/Test-Simple/lib/Test/Stream/IOSets.pm @@ -79,7 +79,7 @@ sub _copy_io_layers { } sub _autoflush { - my($fh) = shift; + my($fh) = pop; my $old_fh = select $fh; $| = 1; select $old_fh; diff --git a/cpan/Test-Simple/lib/Test/Tester.pm b/cpan/Test-Simple/lib/Test/Tester.pm index c0a5cd9ccd..48e6c7d47b 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_075'; +our $VERSION = '1.301001_076'; $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 7e041dc3a8..b1ac43898d 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_075'; +our $VERSION = '1.301001_076'; $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 b6b51e4c66..18c6d2cfe7 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_075'; +our $VERSION = '1.301001_076'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) sub import { diff --git a/cpan/Test-Simple/t/Legacy/fork_die.t b/cpan/Test-Simple/t/Legacy/fork_die.t new file mode 100644 index 0000000000..d649e1a362 --- /dev/null +++ b/cpan/Test-Simple/t/Legacy/fork_die.t @@ -0,0 +1,79 @@ +use strict; +use warnings; + +use Config; + +BEGIN { + my $Can_Fork = $Config{d_fork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config{useithreads} and + $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/ + ); + + if( !$Can_Fork ) { + require Test::More; + Test::More::plan(skip_all => "This system cannot fork"); + exit 0; + } + elsif ($^O eq 'MSWin32' && $] == 5.010000) { + require Test::More; + Test::More::plan('skip_all' => "5.10 has fork/threading issues that break fork on win32"); + exit 0; + } +} + +# The failure case for this test is producing 2 results, 1 pass and 1 fail, +# both with the same test number. If this test file does anything other than 1 +# (non-indented) result that passes, it has failed in one way or another. +use Test::More tests => 1; +use Test::Stream qw/context/; + +my $line; + +subtest do_it => sub { + ok(1, "Pass!"); + + my ($read, $write); + pipe($read, $write) || die "Could not open pipe"; + + my $pid = fork(); + die "Forking failed!" unless defined $pid; + + unless($pid) { + close($read); + Test::Stream::IOSets->_autoflush($write); + my $ctx = context(); + my $handles = $ctx->stream->io_sets->init_encoding('legacy'); + $handles->[0] = $write; + $handles->[1] = $write; + $handles->[2] = $write; + *STDERR = $write; + *STDOUT = $write; + + die "This process did something wrong!"; BEGIN { $line = __LINE__ }; + } + close($write); + + waitpid($pid, 0); + ok($?, "Process exited with failure"); + + { + local $SIG{ALRM} = sub { die "Read Timeout\n" }; + alarm 2; + my @output = map {chomp($_); $_} <$read>; + alarm 0; + is_deeply( + \@output, + [ + "Subtest finished with a new PID ($pid vs $$) while forking support was turned off!", + 'This is almost certainly not what you wanted. Did you fork and forget to exit?', + "This process did something wrong! at t/Legacy/fork_die.t line $line.", + ], + "Got warning and exception, nothing else" + ); + } + + ok(1, "Pass After!"); +}; + +done_testing; |