X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_fork.t;h=bd7054efca03af21327d696aef7a982444600f88;hb=26dd6d9f6575fe782e78d6845fff3447e5ba5744;hp=4ace65c07d3ce7a2fff5ea4bc5ef2fe760a6f058;hpb=09274aae9264de2d08cc7c38c8ca9bf304874b75;p=catagits%2FCatalyst-Runtime.git diff --git a/t/live_fork.t b/t/live_fork.t index 4ace65c..bd7054e 100644 --- a/t/live_fork.t +++ b/t/live_fork.t @@ -15,14 +15,46 @@ use FindBin; use lib "$FindBin::Bin/lib"; use Catalyst::Test qw(TestApp); -plan 'skip_all' if !-e '/bin/ls'; # see if /bin/ls exists -plan tests => 4; # otherwise +plan skip_all => 'Using remote server' + if $ENV{CATALYST_SERVER}; + +plan skip_all => 'Skipping fork tests: no /bin/ls' + if !-e '/bin/ls'; # see if /bin/ls exists + +plan tests => 13; # otherwise -ok(my $result = get('/fork/%2Fbin%2Fls'), 'get /fork//bin/ls'); -my @result = split /$/m, $result; -$result = join "", @result[-4..-1]; +{ + system: + ok(my $result = get('/fork/system/%2Fbin%2Fls'), 'system'); + my @result = split /$/m, $result; + $result = join q{}, @result[-4..-1]; + + my $result_ref = eval { Load($result) }; + ok($result_ref, 'is YAML'); + is($result_ref->{result}, 0, 'exited OK'); +} -my $result_ref = eval { Load($result) }; -ok($result_ref, 'is YAML'); -is($result_ref->{code}, 0, 'exited successfully'); -like($result_ref->{result}, qr{^/bin/ls[^:]}, 'contains ^/bin/ls$'); +{ + backticks: + ok(my $result = get('/fork/backticks/%2Fbin%2Fls'), '`backticks`'); + my @result = split /$/m, $result; + $result = join q{}, @result[-4..-1]; + + my $result_ref = eval { Load($result) }; + ok($result_ref, 'is YAML'); + is($result_ref->{code}, 0, 'exited successfully'); + like($result_ref->{result}, qr{^/bin/ls[^:]}, 'contains ^/bin/ls$'); + like($result_ref->{result}, qr{\n.*\n}m, 'contains two newlines'); +} +{ + fork: + ok(my $result = get('/fork/fork'), 'fork'); + my @result = split /$/m, $result; + $result = join q{}, @result[-4..-1]; + + my $result_ref = eval { Load($result) }; + ok($result_ref, 'is YAML'); + isnt($result_ref->{pid}, 0, q{fork's "pid" wasn't 0}); + isnt($result_ref->{pid}, $$, 'fork got a new pid'); + is($result_ref->{result}, 'ok', 'fork was effective'); +}