From 1ff38955e599b288710c05b96b8ea777391068a1 Mon Sep 17 00:00:00 2001 From: Steve Hay Date: Sat, 29 Nov 2014 13:02:07 +0000 Subject: [PATCH] Skip tests requiring fork() when no fork() is available If you build perl on Windows without -DPERL_IMPLICIT_SYS (which I do, in order to enable -DPEL_MALLOC, which seems faster than using the system malloc()) then you don't get the fork() emulation and several of Plack's tests fail. This commit skips those tests in the same manner as various other CPAN modules do in this case. This allows a normal "cpan install ..." of Plack or anything depending on it (e.g. Dancer) to succeed without having to "force" anything. --- t/HTTP-Server-PSGI/harakiri.t | 7 +++++++ t/HTTP-Server-PSGI/post.t | 7 +++++++ t/Plack-Handler/standalone.t | 7 +++++++ t/Plack-Middleware/component-leak.t | 7 +++++++ t/Plack-Middleware/error_document_streaming_app.t | 7 +++++++ t/Plack-Middleware/stacktrace/sigdie.t | 7 +++++++ t/Plack-Middleware/stacktrace/utf8.t | 7 +++++++ t/Plack-Middleware/urlmap_ports.t | 7 +++++++ t/Plack-Request/double_port.t | 7 +++++++ t/Plack-Request/upload-large.t | 7 +++++++ t/Plack-Test/2args.t | 8 ++++++++ t/Plack-Test/hello_server.t | 7 +++++++ t/Plack-Util/response_cb.t | 7 +++++++ 13 files changed, 92 insertions(+) diff --git a/t/HTTP-Server-PSGI/harakiri.t b/t/HTTP-Server-PSGI/harakiri.t index f104f9a0e..9f5613f38 100644 --- a/t/HTTP-Server-PSGI/harakiri.t +++ b/t/HTTP-Server-PSGI/harakiri.t @@ -1,11 +1,18 @@ use strict; use warnings; +use Config; use Plack::Runner; use Test::More; use Test::TCP; use Test::Requires qw(LWP::UserAgent); +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + my $ua_timeout = 3; test_tcp( diff --git a/t/HTTP-Server-PSGI/post.t b/t/HTTP-Server-PSGI/post.t index 20af84ee2..a56d2bb07 100644 --- a/t/HTTP-Server-PSGI/post.t +++ b/t/HTTP-Server-PSGI/post.t @@ -1,11 +1,18 @@ use strict; use warnings; +use Config; use Plack::Runner; use Test::More; use Test::TCP; use Test::Requires qw(LWP::UserAgent); +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + test_tcp( server => sub { my $port = shift; diff --git a/t/Plack-Handler/standalone.t b/t/Plack-Handler/standalone.t index f5fcf266f..4a516ece3 100644 --- a/t/Plack-Handler/standalone.t +++ b/t/Plack-Handler/standalone.t @@ -1,8 +1,15 @@ use strict; use warnings; +use Config; use Test::More; use Plack::Test::Suite; +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + Plack::Test::Suite->run_server_tests('Standalone'); done_testing(); diff --git a/t/Plack-Middleware/component-leak.t b/t/Plack-Middleware/component-leak.t index 7cdab9914..3563fef1b 100644 --- a/t/Plack-Middleware/component-leak.t +++ b/t/Plack-Middleware/component-leak.t @@ -1,10 +1,17 @@ package MyComponent; use strict; use warnings; +use Config; use Test::More; use Scalar::Util qw/weaken/; use parent 'Plack::Component'; +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + sub call { my $self = shift; my $env = shift; diff --git a/t/Plack-Middleware/error_document_streaming_app.t b/t/Plack-Middleware/error_document_streaming_app.t index b177c536f..d031ef3c8 100644 --- a/t/Plack-Middleware/error_document_streaming_app.t +++ b/t/Plack-Middleware/error_document_streaming_app.t @@ -1,11 +1,18 @@ use strict; use warnings; +use Config; use FindBin; use Test::More; use HTTP::Request::Common; use Plack::Test; use Plack::Builder; +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + $Plack::Test::Impl = undef; my @impl = ('Server', 'MockHTTP'); sub flip_backend { diff --git a/t/Plack-Middleware/stacktrace/sigdie.t b/t/Plack-Middleware/stacktrace/sigdie.t index dc82b2c74..587154aa3 100644 --- a/t/Plack-Middleware/stacktrace/sigdie.t +++ b/t/Plack-Middleware/stacktrace/sigdie.t @@ -1,10 +1,17 @@ use strict; use warnings; +use Config; use Test::More; use Plack::Middleware::StackTrace; use Plack::Test; use HTTP::Request::Common; +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + $Plack::Test::Impl = "Server"; local $ENV{PLACK_SERVER} = "HTTP::Server::PSGI"; diff --git a/t/Plack-Middleware/stacktrace/utf8.t b/t/Plack-Middleware/stacktrace/utf8.t index 6d2f51fff..92aedd2d1 100644 --- a/t/Plack-Middleware/stacktrace/utf8.t +++ b/t/Plack-Middleware/stacktrace/utf8.t @@ -1,11 +1,18 @@ use strict; use warnings; +use Config; use Test::More; use Test::Requires { 'Devel::StackTrace::AsHTML' => 0.08 }; use Plack::Middleware::StackTrace; use Plack::Test; use HTTP::Request::Common; +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + $Plack::Test::Impl = "Server"; local $ENV{PLACK_SERVER} = "HTTP::Server::PSGI"; diff --git a/t/Plack-Middleware/urlmap_ports.t b/t/Plack-Middleware/urlmap_ports.t index 9a0a9c0a6..de82db78a 100644 --- a/t/Plack-Middleware/urlmap_ports.t +++ b/t/Plack-Middleware/urlmap_ports.t @@ -1,9 +1,16 @@ use strict; +use Config; use Test::More; use Plack::App::URLMap; use Plack::Test; use HTTP::Request::Common; +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + $Plack::Test::Impl = "Server"; local $ENV{PLACK_SERVER} = "HTTP::Server::PSGI"; diff --git a/t/Plack-Request/double_port.t b/t/Plack-Request/double_port.t index b5ffdd4ad..d8207897d 100644 --- a/t/Plack-Request/double_port.t +++ b/t/Plack-Request/double_port.t @@ -1,8 +1,15 @@ +use Config; use Test::More; use Plack::Test; use Plack::Request; use HTTP::Request::Common; +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + $Plack::Test::Impl = 'Server'; local $ENV{PLACK_SERVER} = "HTTP::Server::PSGI"; diff --git a/t/Plack-Request/upload-large.t b/t/Plack-Request/upload-large.t index 327a83ace..d64b7cb28 100644 --- a/t/Plack-Request/upload-large.t +++ b/t/Plack-Request/upload-large.t @@ -1,10 +1,17 @@ use strict; use warnings; +use Config; use Test::More; use Plack::Request; use Plack::Test; use HTTP::Request::Common; +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + my $file = "share/baybridge.jpg"; my @backends = qw( Server MockHTTP ); diff --git a/t/Plack-Test/2args.t b/t/Plack-Test/2args.t index 2942f93b3..79af11349 100644 --- a/t/Plack-Test/2args.t +++ b/t/Plack-Test/2args.t @@ -1,6 +1,14 @@ +use Config; use Plack::Test; use Test::More; use HTTP::Request::Common; + +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + $Plack::Test::Impl = "Server"; local $ENV{PLACK_SERVER} = "HTTP::Server::PSGI"; diff --git a/t/Plack-Test/hello_server.t b/t/Plack-Test/hello_server.t index 47ffb75bc..ad03086d2 100644 --- a/t/Plack-Test/hello_server.t +++ b/t/Plack-Test/hello_server.t @@ -1,6 +1,13 @@ +use Config; use Test::More; use Plack::Test; +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + $Plack::Test::Impl = "Server"; local $ENV{PLACK_SERVER} = "HTTP::Server::PSGI"; diff --git a/t/Plack-Util/response_cb.t b/t/Plack-Util/response_cb.t index 813dc871a..34c85cc08 100644 --- a/t/Plack-Util/response_cb.t +++ b/t/Plack-Util/response_cb.t @@ -1,10 +1,17 @@ use strict; use warnings; +use Config; use Plack::Util; use Plack::Test; use Test::More; use HTTP::Request::Common; +plan skip_all => "fork not supported on this platform" + unless $Config::Config{d_fork} || $Config::Config{d_pseudofork} || + (($^O eq 'MSWin32' || $^O eq 'NetWare') and + $Config::Config{useithreads} and + $Config::Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); + $Plack::Test::Impl = "Server"; my $app = sub {