Skip to content

Commit

Permalink
Try fix persistent fail of 62-plack-runner.t
Browse files Browse the repository at this point in the history
This seems to fail frequently via CPAN Testers.  Replaced looking for plack in the PATH with a search through the site/vend bin/script dirs.  If an executable script isn't found, skip the tests.
  • Loading branch information
stash committed Apr 9, 2011
1 parent ad440cb commit fd00b9d
Showing 1 changed file with 37 additions and 28 deletions.
65 changes: 37 additions & 28 deletions t/62-plack-runner.t
Expand Up @@ -10,8 +10,9 @@ BEGIN {
unless eval 'require Test::TCP; $Test::TCP::VERSION >= 1.06';
}

plan tests => 7;
plan tests => 6;
use Test::TCP;
use Config;

test_tcp(
client => sub {
Expand All @@ -36,30 +37,38 @@ test_tcp(
},
);

# XXX: ugh, what's a better cross-platform way of doing this?
my $plackup = `which plackup`;
chomp $plackup;
ok $plackup, 'found plackup';

test_tcp(
client => sub {
my $port = shift;
my $cv = AE::cv;
$cv->begin;
my $cli = simple_client GET => '/',
port => $port,
name => 'plackup runner',
sub {
my ($body,$headers) = @_;
is $headers->{Status}, 200, "script http success";
like $body, qr/^Hello customer number 0x[0-9a-f]+$/;
$cv->end;
};
$cv->recv;
},
server => sub {
my $port = shift;
exec "$^X -Mblib $plackup -E deployment ".
"-s Feersum --listen localhost:$port eg/app.psgi";
},
);
my $plackup;
for my $dir (@Config{qw(sitebin sitescript vendbin vendscript)}) {
my $pu = "$dir/plackup";
if (-e $pu && -x _) {
$plackup = $pu;
diag "plackup: $plackup";
last;
}
}
SKIP: {
skip "can't locate plackup in sitebin/sitescript/vendbin/vendscript", 2
unless $plackup;
test_tcp(
client => sub {
my $port = shift;
my $cv = AE::cv;
$cv->begin;
my $cli = simple_client GET => '/',
port => $port,
name => 'plackup runner',
sub {
my ($body,$headers) = @_;
is $headers->{Status}, 200, "script http success";
like $body, qr/^Hello customer number 0x[0-9a-f]+$/;
$cv->end;
};
$cv->recv;
},
server => sub {
my $port = shift;
exec "$^X -Mblib $plackup -E deployment ".
"-s Feersum --listen localhost:$port eg/app.psgi";
},
);
}

0 comments on commit fd00b9d

Please sign in to comment.