From: Jonathan Rockway Date: Mon, 20 Nov 2006 00:26:17 +0000 (+0000) Subject: adding a failing test -- under dev server, fork() doesn't work X-Git-Tag: 5.7099_04~258 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=09274aae9264de2d08cc7c38c8ca9bf304874b75;p=catagits%2FCatalyst-Runtime.git adding a failing test -- under dev server, fork() doesn't work --- diff --git a/t/lib/TestApp/Controller/Fork.pm b/t/lib/TestApp/Controller/Fork.pm new file mode 100644 index 0000000..fb71c7c --- /dev/null +++ b/t/lib/TestApp/Controller/Fork.pm @@ -0,0 +1,28 @@ +#!/usr/bin/perl +# Fork.pm +# Copyright (c) 2006 Jonathan Rockway + +package TestApp::Controller::Fork; + +use strict; +use warnings; +use base 'Catalyst::Controller'; +use YAML; + +sub fork : Global { + my ($self, $c, $ls) = @_; + my ($result, $code) = (undef, 1); + + if(!-e $ls || !-x _){ + $result = 'skip'; + $code = 0; + } + else { + $result = system($ls, $ls, $ls); + $code = $?; + } + + $c->response->body(Dump({result => $result, code => $code})); +} + +1; diff --git a/t/live_fork.t b/t/live_fork.t new file mode 100644 index 0000000..4ace65c --- /dev/null +++ b/t/live_fork.t @@ -0,0 +1,28 @@ +#!/usr/bin/perl +# live_fork.t +# Copyright (c) 2006 Jonathan Rockway + +=head1 SYNOPSIS + +Tests if Catalyst can fork/exec other processes successfully + +=cut +use strict; +use warnings; +use Test::More; +use YAML; +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 + +ok(my $result = get('/fork/%2Fbin%2Fls'), 'get /fork//bin/ls'); +my @result = split /$/m, $result; +$result = join "", @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$');