diff options
Diffstat (limited to 'cpan/Test-Harness/t/nofork.t')
-rw-r--r-- | cpan/Test-Harness/t/nofork.t | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/cpan/Test-Harness/t/nofork.t b/cpan/Test-Harness/t/nofork.t new file mode 100644 index 0000000000..1d8b340e1b --- /dev/null +++ b/cpan/Test-Harness/t/nofork.t @@ -0,0 +1,59 @@ +#!/usr/bin/perl -w + +# check nofork logic on systems which *can* fork() +# NOTE maybe a good candidate for xt/author or something. + +use lib 't/lib'; + +use strict; + +use Config; +use Test::More ( + $Config{d_fork} + ? 'no_plan' + : ( 'skip_all' => 'your system already has no fork' ) +); +use IO::c55Capture; # for util + +use TAP::Harness; + +sub backticks { + my (@args) = @_; + + util::stdout_of( sub { system(@args) and die "error $?" } ); +} + +my @libs = map "-I$_", @INC; +my @perl = ( $^X, @libs ); +my $mod = 'TAP::Parser::Iterator::Process'; + +{ # just check the introspective method to start... + my $code = qq(print $mod->_use_open3 ? 1 : 2); + { + my $ans = backticks( @perl, '-MNoFork', "-M$mod", '-e', $code ); + is( $ans, 2, 'says not to fork' ); + } + { + local $ENV{PERL5OPT}; # punt: prevent propogating -MNoFork + my $ans = backticks( @perl, "-M$mod", '-e', $code ); + is( $ans, 1, 'says to fork' ); + } +} + +{ # and make sure we can run a test + my $capture = IO::c55Capture->new_handle; + local *STDERR; + my $harness = TAP::Harness->new( + { verbosity => -2, + switches => [ @libs, "-MNoFork" ], + stdout => $capture, + } + ); + $harness->runtests( 't/sample-tests/simple' ); + my @output = tied($$capture)->dump; + is pop @output, "Result: PASS\n", 'status OK'; + pop @output; # get rid of summary line + is( $output[-1], "All tests successful.\n", 'ran with no fork' ); +} + +# vim:ts=4:sw=4:et:sta |