Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
try to find start_server from $PATH and $^X, or skip most tests (but …
…not all) if not found
- Loading branch information
Showing
2 changed files
with
32 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,34 +1,43 @@ | |||
use strict; | use strict; | ||
use warnings; | use warnings; | ||
|
|
||
use File::Basename (); | |||
use LWP::Simple (); | use LWP::Simple (); | ||
use Test::TCP (); | use Test::TCP (); | ||
|
|
||
use Test::More tests => 2; | use Test::More; | ||
|
|
||
BEGIN { | BEGIN { | ||
use_ok('Server::Starter'); | use_ok('Server::Starter'); | ||
}; | }; | ||
|
|
||
my $port = Test::TCP::empty_port(); | my ($start_server) = grep { -x $_ } map { "$_/start_server" } ( | ||
|
File::Basename::dirname($^X), | ||
my $server_pid = fork(); | split /:/, $ENV{PATH}, | ||
die "fork failed:$!" | ); | ||
unless defined $server_pid; |
|
||
if ($server_pid == 0) { | if ($start_server) { | ||
# child == server | my $port = Test::TCP::empty_port(); | ||
exec( | my $server_pid = fork(); | ||
"start_server", | die "fork failed:$!" | ||
"--port=$port", | unless defined $server_pid; | ||
qw(-- plackup -s Standalone::Prefork::Server::Starter t/00base-hello.psgi), | if ($server_pid == 0) { | ||
); | # child == server | ||
die "failed to launch server using start_server:$!"; | exec( | ||
$start_server, | |||
"--port=$port", | |||
qw(-- plackup -s Standalone::Prefork::Server::Starter t/00base-hello.psgi), | |||
); | |||
die "failed to launch server using start_server:$!"; | |||
} | |||
sleep 1; | |||
|
|||
is(LWP::Simple::get("http://127.0.0.1:$port/"), 'hello'); | |||
|
|||
kill 'TERM', $server_pid; | |||
while (wait == -1) {} | |||
} else { | |||
warn "could not find `start_server' next to $^X nor from \$PATH, skipping tests"; | |||
} | } | ||
|
|
||
sleep 1; | done_testing; | ||
|
|||
is(LWP::Simple::get("http://127.0.0.1:$port/"), 'hello'); | |||
|
|||
kill 'TERM', $server_pid; | |||
|
|||
while (wait == -1) {} |