3 # Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>
7 Tests if Catalyst can fork/exec other processes successfully
15 use lib "$FindBin::Bin/lib";
16 use Catalyst::Test qw(TestApp);
18 plan skip_all => 'Using remote server'
19 if $ENV{CATALYST_SERVER};
21 plan skip_all => 'Skipping fork tests: no /bin/ls'
22 if !-e '/bin/ls'; # see if /bin/ls exists
24 plan tests => 13; # otherwise
28 ok(my $result = get('/fork/system/%2Fbin%2Fls'), 'system');
29 my @result = split /$/m, $result;
30 $result = join q{}, @result[-4..-1];
32 my $result_ref = eval { Load($result) };
33 ok($result_ref, 'is YAML');
34 is($result_ref->{result}, 0, 'exited OK');
39 ok(my $result = get('/fork/backticks/%2Fbin%2Fls'), '`backticks`');
40 my @result = split /$/m, $result;
41 $result = join q{}, @result[-4..-1];
43 my $result_ref = eval { Load($result) };
44 ok($result_ref, 'is YAML');
45 is($result_ref->{code}, 0, 'exited successfully');
46 like($result_ref->{result}, qr{^/bin/ls[^:]}, 'contains ^/bin/ls$');
47 like($result_ref->{result}, qr{\n.*\n}m, 'contains two newlines');
51 ok(my $result = get('/fork/fork'), 'fork');
52 my @result = split /$/m, $result;
53 $result = join q{}, @result[-4..-1];
55 my $result_ref = eval { Load($result) };
56 ok($result_ref, 'is YAML');
57 isnt($result_ref->{pid}, 0, q{fork's "pid" wasn't 0});
58 isnt($result_ref->{pid}, $$, 'fork got a new pid');
59 is($result_ref->{result}, 'ok', 'fork was effective');