Permalink
Browse files

improve the runner test, negating a FIXME

  • Loading branch information...
1 parent 894c9cb commit 29ef597dec9fe2e24882a42e02e1cce5e17248dd @stash committed Jan 4, 2011
Showing with 47 additions and 39 deletions.
  1. +47 −39 t/62-plack-runner.t
View
@@ -10,56 +10,64 @@ BEGIN {
unless eval 'require Test::TCP; $Test::TCP::VERSION >= 1.06';
}
-plan tests => 7;
+plan tests => 10;
use Test::TCP;
+use File::Spec ();
+use Config;
+
+my $eg = File::Spec->catfile('eg','app.psgi');
+my $eg_feersum = File::Spec->catfile('eg','app.feersum');
+
+my $plackup = File::Spec->catfile($Config{sitescriptexp}, "plackup");
+ok -e $plackup, 'found plackup';
+
+sub run_client {
+ my ($name, $port) = @_;
+ my $cv = AE::cv;
+ $cv->begin;
+ my $cli = simple_client GET => '/',
+ port => $port,
+ name => $name,
+ 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;
+}
test_tcp(
- client => sub {
- my $port = shift;
- my $cv = AE::cv;
- $cv->begin;
- my $cli = simple_client GET => '/',
- port => $port,
- name => 'feersum 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;
- },
+ client => sub { run_client('feersum psgi runner',shift) },
server => sub {
my $port = shift;
- exec "$^X -Mblib blib/script/feersum --listen localhost:$port ".
- "eg/app.psgi";
+ exec $^X, '-Mblib',
+ File::Spec->catfile('blib','script','feersum'),
+ '--listen' => "localhost:$port",
+ $eg;
},
);
-# 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 {
+ client => sub { run_client('plackup psgi runner',shift) },
+ server => 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;
- },
+ exec $^X, '-Mblib', $plackup,
+ '-E' => 'deployment',
+ '-s' => 'Feersum',
+ '--listen' => "localhost:$port",
+ $eg;
+ },
+);
+
+test_tcp(
+ client => sub { run_client('feersum native runner',shift) },
server => sub {
my $port = shift;
- exec "$^X -Mblib $plackup -E deployment ".
- "-s Feersum --listen localhost:$port eg/app.psgi";
+ exec $^X, '-Mblib',
+ File::Spec->catfile('blib','script','feersum'),
+ '--native',
+ '--listen' => "localhost:$port",
+ $eg_feersum;
},
);

0 comments on commit 29ef597

Please sign in to comment.