summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple
diff options
context:
space:
mode:
authorChad Granum <chad.granum@dreamhost.com>2014-11-23 16:24:50 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-23 17:41:32 -0800
commit2e52a9b8712c6c0077b2c34feaedc8404f7af7d5 (patch)
tree7f61bd12287163da13918f5c762df3f6b6276e72 /cpan/Test-Simple
parente41e9865be5555602763ac0cf98065a8f3f38189 (diff)
downloadperl-2e52a9b8712c6c0077b2c34feaedc8404f7af7d5.tar.gz
Update Test-Simple to Alpha 078
Diffstat (limited to 'cpan/Test-Simple')
-rw-r--r--cpan/Test-Simple/lib/Test/Builder.pm2
-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/CanFork.pm94
-rw-r--r--cpan/Test-Simple/lib/Test/CanThread.pm103
-rw-r--r--cpan/Test-Simple/lib/Test/More.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Simple.pm4
-rw-r--r--cpan/Test-Simple/lib/Test/Stream.pm2
-rw-r--r--cpan/Test-Simple/lib/Test/Stream/ForceExit.pm97
-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/388-threadedsubtest.t26
-rw-r--r--cpan/Test-Simple/t/Behavior/fork_new_end.t25
-rw-r--r--cpan/Test-Simple/t/Behavior/threads_with_taint_mode.t41
-rw-r--r--cpan/Test-Simple/t/Legacy/Builder/fork_with_new_stdout.t20
-rw-r--r--cpan/Test-Simple/t/Legacy/fork.t19
-rw-r--r--cpan/Test-Simple/t/Legacy/fork_die.t19
-rw-r--r--cpan/Test-Simple/t/Legacy/fork_in_subtest.t21
-rw-r--r--cpan/Test-Simple/t/Legacy/is_deeply_with_threads.t23
-rw-r--r--cpan/Test-Simple/t/Legacy/ribasushi_threads.t35
-rw-r--r--cpan/Test-Simple/t/Legacy/ribasushi_threads2.t32
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/fork.t22
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/threads.t10
-rw-r--r--cpan/Test-Simple/t/Legacy/threads.t24
-rw-r--r--cpan/Test-Simple/t/Test-Stream-ForceExit.t69
27 files changed, 407 insertions, 295 deletions
diff --git a/cpan/Test-Simple/lib/Test/Builder.pm b/cpan/Test-Simple/lib/Test/Builder.pm
index aa9a417187..2144c93456 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_076';
+our $VERSION = '1.301001_078';
$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 79340ed18d..0ff9ce1a9d 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_076';
+our $VERSION = '1.301001_078';
$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 dfdfc5e0e0..7b2e9b46e1 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_076';
+our $VERSION = '1.301001_078';
$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 6498c6acb3..dfdb50d262 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_076';
+our $VERSION = '1.301001_078';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Stream 1.301001 '-internal';
diff --git a/cpan/Test-Simple/lib/Test/CanFork.pm b/cpan/Test-Simple/lib/Test/CanFork.pm
new file mode 100644
index 0000000000..b28a38226c
--- /dev/null
+++ b/cpan/Test-Simple/lib/Test/CanFork.pm
@@ -0,0 +1,94 @@
+package Test::CanFork;
+use strict;
+use warnings;
+
+use Config;
+
+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;
+}
+
+if ($^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;
+}
+
+sub import {
+ my $class = shift;
+ for my $var (@_) {
+ next if $ENV{$var};
+
+ require Test::More;
+ Test::More::plan(skip_all => "This forking test will only run when the '$var' environment variable is set.");
+ exit 0;
+ }
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Test::CanFork - Only run tests when forking is supported, optionally conditioned on ENV vars.
+
+=head1 DESCRIPTION
+
+Use this first thing in a test that should be skipped when forking is not
+supported. You can also specify that the test should be skipped when specific
+environment variables are not set.
+
+=head1 SYNOPSYS
+
+Skip the test if forking is unsupported:
+
+ use Test::CanFork;
+ use Test::More;
+ ...
+
+Skip the test if forking is unsupported, or any of the specified env vars are
+not set:
+
+ use Test::CanFork qw/AUTHOR_TESTING RUN_PROBLEMATIC_TESTS .../;
+ use Test::More;
+ ...
+
+=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
+
+=over 4
+
+=item Chad Granum E<lt>exodist@cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT
+
+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>
+
+=cut
diff --git a/cpan/Test-Simple/lib/Test/CanThread.pm b/cpan/Test-Simple/lib/Test/CanThread.pm
new file mode 100644
index 0000000000..a9d6aeb106
--- /dev/null
+++ b/cpan/Test-Simple/lib/Test/CanThread.pm
@@ -0,0 +1,103 @@
+package Test::CanThread;
+use strict;
+use warnings;
+
+use Config;
+
+if ($] == 5.010000) {
+ require Test::More;
+ Test::More::plan(skip_all => "Threads are broken on 5.10.0");
+ exit 0;
+}
+
+my $works = 1;
+$works &&= $] >= 5.008001;
+$works &&= $Config{'useithreads'};
+$works &&= eval { require threads; 'threads'->import; 1 };
+
+unless ($works) {
+ require Test::More;
+ Test::More::plan(skip_all => "Skip no working threads");
+ exit 0;
+}
+
+if ($INC{'Devel/Cover.pm'}) {
+ require Test::More;
+ Test::More::plan(skip_all => "Devel::Cover does not work with threads yet");
+ exit 0;
+}
+
+sub import {
+ my $class = shift;
+ while(my $var = shift(@_)) {
+ next if $ENV{$var};
+
+ require Test::More;
+ Test::More::plan(skip_all => "This threaded test will only run when the '$var' environment variable is set.");
+ exit 0;
+ }
+
+ unshift @_ => 'threads';
+ goto &threads::import;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Test::CanThread - Only run tests when threading is supported, optionally conditioned on ENV vars.
+
+=head1 DESCRIPTION
+
+Use this first thing in a test that should be skipped when threading is not
+supported. You can also specify that the test should be skipped when specific
+environment variables are not set.
+
+=head1 SYNOPSYS
+
+Skip the test if threading is unsupported:
+
+ use Test::CanThread;
+ use Test::More;
+ ...
+
+Skip the test if threading is unsupported, or any of the specified env vars are
+not set:
+
+ use Test::CanThread qw/AUTHOR_TESTING RUN_PROBLEMATIC_TESTS .../;
+ use Test::More;
+ ...
+
+=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
+
+=over 4
+
+=item Chad Granum E<lt>exodist@cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT
+
+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>
+
+=cut
diff --git a/cpan/Test-Simple/lib/Test/More.pm b/cpan/Test-Simple/lib/Test/More.pm
index d1b7e65caa..585fd8a48a 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_076';
+our $VERSION = '1.301001_078';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Stream 1.301001 '-internal';
diff --git a/cpan/Test-Simple/lib/Test/Simple.pm b/cpan/Test-Simple/lib/Test/Simple.pm
index 297c4905d4..61cc2c3c93 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_076';
+our $VERSION = '1.301001_078';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
-use Test::Stream 1.301001_076 '-internal';
+use Test::Stream 1.301001_078 '-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 6decda349e..2011c5b767 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_076';
+our $VERSION = '1.301001_078';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
use Test::Stream::Context qw/context/;
diff --git a/cpan/Test-Simple/lib/Test/Stream/ForceExit.pm b/cpan/Test-Simple/lib/Test/Stream/ForceExit.pm
new file mode 100644
index 0000000000..e32edfb8b4
--- /dev/null
+++ b/cpan/Test-Simple/lib/Test/Stream/ForceExit.pm
@@ -0,0 +1,97 @@
+package Test::Stream::ForceExit;
+use strict;
+use warnings;
+
+sub new {
+ my $class = shift;
+
+ my $done = 0;
+ my $self = \$done;
+
+ return bless $self, $class;
+}
+
+sub done {
+ my $self = shift;
+ ($$self) = @_ if @_;
+ return $$self;
+}
+
+sub DESTROY {
+ my $self = shift;
+ return if $self->done;
+
+ warn "Something prevented child process $$ from exiting when it should have, Forcing exit now!\n";
+ $self->done(1); # Prevent duplicate message during global destruction
+ exit 255;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Test::ForceExit - Ensure C<exit()> is called bvy the end of a scope, force the issue.
+
+=head1 DESCRIPTION
+
+Sometimes you need to fork. Sometimes the forked process can throw an exception
+to exit. If you forked below an eval the exception will be cought and you
+suddenly have an unexpected process running amok. This module can be used to
+protect you from such issues.
+
+=head1 SYNOPSYS
+
+ eval {
+ ...
+
+ my $pid = fork;
+
+ unless($pid) {
+ require Test::Stream::ForceExit;
+ my $force_exit = Test::Stream::ForceExit->new;
+
+ thing_that_can_die();
+
+ # We did not die, turn off the forced exit.
+ $force_exit->done(1);
+
+ # Do the exit we intend.
+ exit 0;
+ }
+
+ ...
+ }
+
+=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
+
+=over 4
+
+=item Chad Granum E<lt>exodist@cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT
+
+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>
+
+=cut
diff --git a/cpan/Test-Simple/lib/Test/Tester.pm b/cpan/Test-Simple/lib/Test/Tester.pm
index 48e6c7d47b..5fd8b11311 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_076';
+our $VERSION = '1.301001_078';
$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 b1ac43898d..72e94372ab 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_076';
+our $VERSION = '1.301001_078';
$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 18c6d2cfe7..b83c7ec528 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_076';
+our $VERSION = '1.301001_078';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
sub import {
diff --git a/cpan/Test-Simple/t/Behavior/388-threadedsubtest.t b/cpan/Test-Simple/t/Behavior/388-threadedsubtest.t
index 44a586c843..fae3783f0e 100644
--- a/cpan/Test-Simple/t/Behavior/388-threadedsubtest.t
+++ b/cpan/Test-Simple/t/Behavior/388-threadedsubtest.t
@@ -2,31 +2,7 @@
use strict;
use warnings;
-use Config;
-
-BEGIN {
- if ($] == 5.010000) {
- print "1..0 # Threads are broken on 5.10.0\n";
- exit 0;
- }
-
- my $works = 1;
- $works &&= $] >= 5.008001;
- $works &&= $Config{'useithreads'};
- $works &&= eval { require threads; 'threads'->import; 1 };
-
- unless ($works) {
- print "1..0 # Skip no working threads\n";
- exit 0;
- }
-
- unless ( $ENV{AUTHOR_TESTING} ) {
- print "1..0 # Skip many perls have broken threads. Enable with AUTHOR_TESTING.\n";
- exit 0;
- }
-}
-
-use threads;
+use Test::CanThread qw/AUTHOR_TESTING/;
use Test::More;
subtest my_subtest => sub {
diff --git a/cpan/Test-Simple/t/Behavior/fork_new_end.t b/cpan/Test-Simple/t/Behavior/fork_new_end.t
index d15b9d9164..7e7c2d7c25 100644
--- a/cpan/Test-Simple/t/Behavior/fork_new_end.t
+++ b/cpan/Test-Simple/t/Behavior/fork_new_end.t
@@ -8,30 +8,7 @@ BEGIN {
}
}
-use Config;
-
-BEGIN {
- if ($] == 5.010000) {
- print "1..0 # Threads are broken on 5.10.0\n";
- exit 0;
- }
-
- my $works = 1;
- $works &&= $] >= 5.008001;
- $works &&= $Config{'useithreads'};
- $works &&= eval { require threads; 'threads'->import; 1 };
-
- unless ($works) {
- print "1..0 # Skip no working threads\n";
- exit 0;
- }
-
- unless ( $ENV{AUTHOR_TESTING} ) {
- print "1..0 # Skip many perls have broken threads. Enable with AUTHOR_TESTING.\n";
- exit 0;
- }
-}
-
+use Test::CanThread qw/AUTHOR_TESTING/;
use Test::More tests => 4;
ok(1, "outside before");
diff --git a/cpan/Test-Simple/t/Behavior/threads_with_taint_mode.t b/cpan/Test-Simple/t/Behavior/threads_with_taint_mode.t
index 5f73ffaac2..71a80e932b 100644
--- a/cpan/Test-Simple/t/Behavior/threads_with_taint_mode.t
+++ b/cpan/Test-Simple/t/Behavior/threads_with_taint_mode.t
@@ -1,47 +1,28 @@
#!/usr/bin/perl -w -T
+use strict;
+use warnings;
BEGIN {
- if( $ENV{PERL_CORE} ) {
+ if ($ENV{PERL_CORE}) {
chdir 't';
@INC = '../lib';
}
}
-use Config;
-
-BEGIN {
- if ($] == 5.010000) {
- print "1..0 # Threads are broken on 5.10.0\n";
- exit 0;
- }
-
- my $works = 1;
- $works &&= $] >= 5.008001;
- $works &&= $Config{'useithreads'};
- $works &&= eval { require threads; 'threads'->import; 1 };
+use Test::CanThread qw/AUTHOR_TESTING/;
- unless ($works) {
- print "1..0 # Skip no working threads\n";
- exit 0;
- }
-
- unless ( $ENV{AUTHOR_TESTING} ) {
- print "1..0 # Skip many perls have broken threads. Enable with AUTHOR_TESTING.\n";
- exit 0;
- }
-}
-
-use strict;
use Test::Builder;
my $Test = Test::Builder->new;
$Test->exported_to('main');
$Test->plan(tests => 6);
-for(1..5) {
- 'threads'->create(sub {
- $Test->ok(1,"Each of these should app the test number")
- })->join;
+for (1 .. 5) {
+ 'threads'->create(
+ sub {
+ $Test->ok(1, "Each of these should app the test number");
+ }
+ )->join;
}
-$Test->is_num($Test->current_test(), 5,"Should be five");
+$Test->is_num($Test->current_test(), 5, "Should be five");
diff --git a/cpan/Test-Simple/t/Legacy/Builder/fork_with_new_stdout.t b/cpan/Test-Simple/t/Legacy/Builder/fork_with_new_stdout.t
index 5e20d8126e..5adb739eb2 100644
--- a/cpan/Test-Simple/t/Legacy/Builder/fork_with_new_stdout.t
+++ b/cpan/Test-Simple/t/Legacy/Builder/fork_with_new_stdout.t
@@ -1,27 +1,15 @@
#!perl -w
use strict;
use warnings;
+
+use Test::CanFork;
+
use IO::Pipe;
use Test::Builder;
-use Config;
my $b = Test::Builder->new;
$b->reset;
-
-my $Can_Fork = $Config{d_fork}
- || (($^O eq 'MSWin32' || $^O eq 'NetWare')
- and $Config{useithreads}
- and $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/);
-
-if (!$Can_Fork) {
- $b->plan('skip_all' => "This system cannot fork");
-}
-elsif ($^O eq 'MSWin32' && $] == 5.010000) {
- $b->plan('skip_all' => "5.10 has fork/threading issues that break fork on win32");
-}
-else {
- $b->plan('tests' => 2);
-}
+$b->plan('tests' => 2);
my $pipe = IO::Pipe->new;
if (my $pid = fork) {
diff --git a/cpan/Test-Simple/t/Legacy/fork.t b/cpan/Test-Simple/t/Legacy/fork.t
index ad02824f52..da7d4646ad 100644
--- a/cpan/Test-Simple/t/Legacy/fork.t
+++ b/cpan/Test-Simple/t/Legacy/fork.t
@@ -7,24 +7,9 @@ BEGIN {
}
}
-use Test::More;
-use Config;
+use Test::CanFork;
-my $Can_Fork = $Config{d_fork} ||
- (($^O eq 'MSWin32' || $^O eq 'NetWare') and
- $Config{useithreads} and
- $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/
- );
-
-if( !$Can_Fork ) {
- plan skip_all => "This system cannot fork";
-}
-elsif ($^O eq 'MSWin32' && $] == 5.010000) {
- plan 'skip_all' => "5.10 has fork/threading issues that break fork on win32";
-}
-else {
- plan tests => 1;
-}
+use Test::More tests => 1;
my $pid = fork;
if( $pid ) { # parent
diff --git a/cpan/Test-Simple/t/Legacy/fork_die.t b/cpan/Test-Simple/t/Legacy/fork_die.t
index d649e1a362..6728e28873 100644
--- a/cpan/Test-Simple/t/Legacy/fork_die.t
+++ b/cpan/Test-Simple/t/Legacy/fork_die.t
@@ -1,27 +1,16 @@
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) {
+ if ($^O eq 'MSWin32' || $^O eq 'NetWare') {
require Test::More;
- Test::More::plan('skip_all' => "5.10 has fork/threading issues that break fork on win32");
+ Test::More::plan(skip_all => "This test is unreliable on $^O, also not likely to be helpful");
exit 0;
}
}
+use Test::CanFork;
+
# 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.
diff --git a/cpan/Test-Simple/t/Legacy/fork_in_subtest.t b/cpan/Test-Simple/t/Legacy/fork_in_subtest.t
index b89cc5c19a..1a8dc16f39 100644
--- a/cpan/Test-Simple/t/Legacy/fork_in_subtest.t
+++ b/cpan/Test-Simple/t/Legacy/fork_in_subtest.t
@@ -1,26 +1,7 @@
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;
- }
-}
+use Test::CanFork;
use Test::Stream 'enable_fork';
use Test::More;
diff --git a/cpan/Test-Simple/t/Legacy/is_deeply_with_threads.t b/cpan/Test-Simple/t/Legacy/is_deeply_with_threads.t
index 66a6641fa7..50d20042fd 100644
--- a/cpan/Test-Simple/t/Legacy/is_deeply_with_threads.t
+++ b/cpan/Test-Simple/t/Legacy/is_deeply_with_threads.t
@@ -13,29 +13,8 @@ BEGIN {
}
use strict;
-use Config;
-BEGIN {
- if ($] == 5.010000) {
- print "1..0 # Threads are broken on 5.10.0\n";
- exit 0;
- }
-
- my $works = 1;
- $works &&= $] >= 5.008001;
- $works &&= $Config{'useithreads'};
- $works &&= eval { require threads; 'threads'->import; 1 };
-
- unless ($works) {
- print "1..0 # Skip no working threads\n";
- exit 0;
- }
-
- unless ( $ENV{AUTHOR_TESTING} ) {
- print "1..0 # Skip many perls have broken threads. Enable with AUTHOR_TESTING.\n";
- exit 0;
- }
-}
+use Test::CanThread qw/AUTHOR_TESTING/;
use Test::More;
diff --git a/cpan/Test-Simple/t/Legacy/ribasushi_threads.t b/cpan/Test-Simple/t/Legacy/ribasushi_threads.t
index 32a7d1f0ae..bbf3b67c3e 100644
--- a/cpan/Test-Simple/t/Legacy/ribasushi_threads.t
+++ b/cpan/Test-Simple/t/Legacy/ribasushi_threads.t
@@ -1,37 +1,4 @@
-use Config;
-
-BEGIN {
- if ($] == 5.010000) {
- print "1..0 # Threads are broken on 5.10.0\n";
- exit 0;
- }
-
- my $works = 1;
- $works &&= $] >= 5.008001;
- $works &&= $Config{'useithreads'};
- $works &&= eval { require threads; 'threads'->import; 1 };
-
- unless ($works) {
- print "1..0 # Skip no working threads\n";
- exit 0;
- }
-
- unless ($ENV{AUTHOR_TESTING}) {
- print "1..0 # Skip many perls have broken threads. Enable with AUTHOR_TESTING.\n";
- exit 0;
- }
-
- if ($INC{'Devel/Cover.pm'}) {
- print "1..0 # SKIP Devel::Cover does not work with threads yet\n";
- exit 0;
- }
-}
-
-use threads;
-
-use strict;
-use warnings;
-
+use Test::CanThread qw/AUTHOR_TESTING/;
use Test::More;
# basic tests
diff --git a/cpan/Test-Simple/t/Legacy/ribasushi_threads2.t b/cpan/Test-Simple/t/Legacy/ribasushi_threads2.t
index c60c61e650..411a46315d 100644
--- a/cpan/Test-Simple/t/Legacy/ribasushi_threads2.t
+++ b/cpan/Test-Simple/t/Legacy/ribasushi_threads2.t
@@ -1,37 +1,7 @@
-use Config;
-
-BEGIN {
- if ($] == 5.010000) {
- print "1..0 # Threads are broken on 5.10.0\n";
- exit 0;
- }
-
- my $works = 1;
- $works &&= $] >= 5.008001;
- $works &&= $Config{'useithreads'};
- $works &&= eval { require threads; 'threads'->import; 1 };
-
- unless ($works) {
- print "1..0 # Skip no working threads\n";
- exit 0;
- }
-
- unless ($ENV{AUTHOR_TESTING}) {
- print "1..0 # Skip many perls have broken threads. Enable with AUTHOR_TESTING.\n";
- exit 0;
- }
-
- if ($INC{'Devel/Cover.pm'}) {
- print "1..0 # SKIP Devel::Cover does not work with threads yet\n";
- exit 0;
- }
-}
-
-use threads;
-
use strict;
use warnings;
+use Test::CanThread qw/AUTHOR_TESTING/;
use Test::More;
{
diff --git a/cpan/Test-Simple/t/Legacy/subtest/fork.t b/cpan/Test-Simple/t/Legacy/subtest/fork.t
index 76e949329b..8d763a49fd 100644
--- a/cpan/Test-Simple/t/Legacy/subtest/fork.t
+++ b/cpan/Test-Simple/t/Legacy/subtest/fork.t
@@ -1,26 +1,12 @@
#!/usr/bin/perl -w
use strict;
use warnings;
-use Config;
+
+use Test::CanFork;
+
use IO::Pipe;
use Test::Builder;
-use Test::More;
-
-my $Can_Fork = $Config{d_fork} ||
- (($^O eq 'MSWin32' || $^O eq 'NetWare') and
- $Config{useithreads} and
- $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/
- );
-
-if( !$Can_Fork ) {
- plan 'skip_all' => "This system cannot fork";
-}
-elsif ($^O eq 'MSWin32' && $] == 5.010000) {
- plan 'skip_all' => "5.10 has fork/threading issues that break fork on win32";
-}
-else {
- plan 'tests' => 1;
-}
+use Test::More tests => 1;
subtest 'fork within subtest' => sub {
plan tests => 2;
diff --git a/cpan/Test-Simple/t/Legacy/subtest/threads.t b/cpan/Test-Simple/t/Legacy/subtest/threads.t
index 5d053ca2db..df00f40c04 100644
--- a/cpan/Test-Simple/t/Legacy/subtest/threads.t
+++ b/cpan/Test-Simple/t/Legacy/subtest/threads.t
@@ -3,15 +3,7 @@
use strict;
use warnings;
-use Config;
-BEGIN {
- unless ( $] >= 5.008001 && $Config{'useithreads'} &&
- eval { require threads; 'threads'->import; 1; })
- {
- print "1..0 # Skip: no working threads\n";
- exit 0;
- }
-}
+use Test::CanThread;
use Test::More;
diff --git a/cpan/Test-Simple/t/Legacy/threads.t b/cpan/Test-Simple/t/Legacy/threads.t
index 51b374d9f9..28b0bd1d61 100644
--- a/cpan/Test-Simple/t/Legacy/threads.t
+++ b/cpan/Test-Simple/t/Legacy/threads.t
@@ -7,29 +7,7 @@ BEGIN {
}
}
-use Config;
-
-BEGIN {
- if ($] == 5.010000) {
- print "1..0 # Threads are broken on 5.10.0\n";
- exit 0;
- }
-
- my $works = 1;
- $works &&= $] >= 5.008001;
- $works &&= $Config{'useithreads'};
- $works &&= eval { require threads; 'threads'->import; 1 };
-
- unless ($works) {
- print "1..0 # Skip no working threads\n";
- exit 0;
- }
-
- unless ( $ENV{AUTHOR_TESTING} ) {
- print "1..0 # Skip many perls have broken threads. Enable with AUTHOR_TESTING.\n";
- exit 0;
- }
-}
+use Test::CanThread qw/AUTHOR_TESTING/;
use strict;
use Test::Builder;
diff --git a/cpan/Test-Simple/t/Test-Stream-ForceExit.t b/cpan/Test-Simple/t/Test-Stream-ForceExit.t
new file mode 100644
index 0000000000..6bae48c788
--- /dev/null
+++ b/cpan/Test-Simple/t/Test-Stream-ForceExit.t
@@ -0,0 +1,69 @@
+use Test::Stream::ForceExit;
+use strict;
+use warnings;
+
+use Test::CanFork;
+
+use Test::Stream qw/enable_fork/;
+use Test::More;
+use Test::Stream::ForceExit;
+
+my ($read, $write);
+pipe($read, $write) || die "Failed to create a pipe.";
+
+my $pid = fork();
+unless ($pid) {
+ die "Failed to fork" unless defined $pid;
+ close($read);
+ $SIG{__WARN__} = sub { print $write @_ };
+
+ {
+ my $force_exit = Test::Stream::ForceExit->new;
+ diag "In Child";
+ }
+
+ print $write "Did not exit!";
+
+ ok(0, "Failed to exit");
+ exit 0;
+}
+
+close($write);
+waitpid($pid, 0);
+my $error = $?;
+ok($error, "Got an error");
+my $msg = join("", <$read>);
+is($msg, <<EOT, "Got warning");
+Something prevented child process $pid from exiting when it should have, Forcing exit now!
+EOT
+
+close($read);
+pipe($read, $write) || die "Failed to create a pipe.";
+
+$pid = fork();
+unless ($pid) {
+ die "Failed to fork" unless defined $pid;
+ close($read);
+ $SIG{__WARN__} = sub { print $write @_ };
+
+ {
+ my $force_exit = Test::Stream::ForceExit->new;
+ diag "In Child $$";
+ $force_exit->done(1);
+ }
+
+ print $write "Did not exit!\n";
+
+ exit 0;
+}
+
+close($write);
+waitpid($pid, 0);
+$error = $?;
+ok(!$error, "no error");
+$msg = join("", <$read>);
+is($msg, <<EOT, "Did not exit early");
+Did not exit!
+EOT
+
+done_testing;