adding a backticks test in addition to system()
[catagits/Catalyst-Runtime.git] / t / live_fork.t
CommitLineData
09274aae 1#!/usr/bin/perl
2# live_fork.t
3# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>
4
5=head1 SYNOPSIS
6
7Tests if Catalyst can fork/exec other processes successfully
8
9=cut
10use strict;
11use warnings;
12use Test::More;
13use YAML;
14use FindBin;
15use lib "$FindBin::Bin/lib";
16use Catalyst::Test qw(TestApp);
17
18plan 'skip_all' if !-e '/bin/ls'; # see if /bin/ls exists
8d5f3e92 19plan tests => 8; # otherwise
09274aae 20
8d5f3e92 21{
22 fork:
23 ok(my $result = get('/fork/fork/%2Fbin%2Fls'), 'get /fork//bin/ls');
24 my @result = split /$/m, $result;
25 $result = join q{}, @result[-4..-1];
26
27 my $result_ref = eval { Load($result) };
28 ok($result_ref, 'is YAML');
29 is($result_ref->{code}, 0, 'exited successfully');
30 like($result_ref->{result}, qr{^/bin/ls[^:]}, 'contains ^/bin/ls$');
31}
09274aae 32
8d5f3e92 33{
34 backticks:
35 ok(my $result = get('/fork/backticks/%2Fbin%2Fls'), 'get /fork//bin/ls');
36 my @result = split /$/m, $result;
37 $result = join q{}, @result[-4..-1];
38
39 my $result_ref = eval { Load($result) };
40 ok($result_ref, 'is YAML');
41 is($result_ref->{code}, 0, 'exited successfully');
42 like($result_ref->{result}, qr{^/bin/ls[^:]}, 'contains ^/bin/ls$');
43}