X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FTestApp%2FController%2FFork.pm;h=5690efa5cd24b9eaaefc788a25c536850de0e60c;hb=fe82a51db5b44026493ce2a6e05c0f233ddfb4dd;hp=086d1490445477dc28627aa8c876ce35f3e32162;hpb=15f0ede8ee33bc9b0c002221a8e62f59e8b7b7e2;p=catagits%2FCatalyst-Runtime.git diff --git a/t/lib/TestApp/Controller/Fork.pm b/t/lib/TestApp/Controller/Fork.pm index 086d149..5690efa 100644 --- a/t/lib/TestApp/Controller/Fork.pm +++ b/t/lib/TestApp/Controller/Fork.pm @@ -1,5 +1,4 @@ -#!/usr/bin/perl -# Fork.pm +# Fork.pm # Copyright (c) 2006 Jonathan Rockway package TestApp::Controller::Fork; @@ -8,28 +7,28 @@ use strict; use warnings; use base 'Catalyst::Controller'; -eval 'use YAML'; +use JSON::MaybeXS qw(encode_json); sub system : Local { my ($self, $c, $ls) = @_; my ($result, $code) = (undef, 1); - if(!-e $ls || !-x _){ + if(!-e $ls || !-x _){ $result = 'skip'; } else { $result = system($ls, $ls, $ls); $result = $! if $result != 0; } - - $c->response->body(Dump({result => $result})); + + $c->response->body(encode_json({result => $result})); } sub backticks : Local { my ($self, $c, $ls) = @_; my ($result, $code) = (undef, 1); - - if(!-e $ls || !-x _){ + + if(!-e $ls || !-x _){ $result = 'skip'; $code = 0; } @@ -37,15 +36,15 @@ sub backticks : Local { $result = `$ls $ls $ls` || $!; $code = $?; } - - $c->response->body(Dump({result => $result, code => $code})); + + $c->response->body(encode_json({result => $result, code => $code})); } sub fork : Local { my ($self, $c) = @_; my $pid; my $x = 0; - + if($pid = fork()){ $x = "ok"; } @@ -54,8 +53,8 @@ sub fork : Local { } waitpid $pid,0 or die; - - $c->response->body(Dump({pid => $pid, result => $x})); + + $c->response->body(encode_json({pid => $pid, result => $x})); } 1;