On Thu, Feb 05, 2009 at 04:28:57PM +0100, Florian Ragwitz wrote:
> On Thu, Feb 05, 2009 at 07:10:07AM -0800, Bill Moseley wrote:
> > Same problem.
> 
> Would you mind preparing a testcase for this?

I can try.  See attached diff against svn 9215.

$ prove -vl t/live_fork.t 
t/live_fork....
1..15
TestApp is trying to use NEXT, which is deprecated. Please see the 
Class::C3::Adopt::NEXT documentation for details at 
/home/moseley/cat_5.8/t/lib/Catalyst/Plugin/Test/Plugin.pm line 23
ok 1 - system
ok 2 - is YAML
ok 3 - exited OK
ok 4 - `backticks`
ok 5 - is YAML
ok 6 - exited successfully
ok 7 - contains ^/bin/ls$
ok 8 - contains two newlines
ok 9 - fork
ok 10 - is YAML
ok 11 - fork's "pid" wasn't 0
ok 12 - fork got a new pid
ok 13 - fork was effective
ok 14 - io_pipe
ok 15 - io_pipe returned data from handle
ok
All tests successful.
Files=1, Tests=15,  1 wallclock secs ( 0.02 usr  0.01 sys +  0.98 cusr  0.06 
csys =  1.07 CPU)
Result: PASS



> 
> TestApp::Controller::Fork / t/live_fork.t already has similar tests. You
> can run them against the dev server using t/optional_http-server.t.

Should App::Prove be listed as a dependency in test_requires?
(although test_requires doesn't seem to work like I think it should.  ;)


Not 100% clear on how to run it but here's my attempt:
(trimmed a bit):

$ TEST_HTTP=1 REMOTE_FORK=1 perl -Ilib t/optional_http-server.t t/live_fork.t 
1..1
created "TestApp"
created "TestApp/script"
[...]
Waiting for server to start...
1..15
ok 1 - system
Use of uninitialized value in join or string at t/live_fork.t line 32.
ok 2 - is YAML
ok 3 - exited OK
ok 4 - `backticks`
ok 5 - is YAML
ok 6 - exited successfully
ok 7 - contains ^/bin/ls$
ok 8 - contains two newlines
ok 9 - fork
ok 10 - is YAML
ok 11 - fork's "pid" wasn't 0
ok 12 - fork got a new pid
ok 13 - fork was effective
ok 14 - io_pipe
not ok 15 - io_pipe returned data from handle
#   Failed test 'io_pipe returned data from handle'
#   at t/live_fork.t line 70.
#          got: 'FATAL ERROR: Caught exception in 
TestApp::Controller::Fork->io_pipe "Failed read from IO::Pipe handle at 
/home/moseley/cat_5.8/t/tmp/TestApp/script/../lib/TestApp/Controller/Fork.pm 
line 72."'
#     expected: 'ok'
# Looks like you failed 1 test of 15.
not ok 1 - live tests
#   Failed test 'live tests'
#   at t/optional_http-server.t line 69.
#          got: '256'
#     expected: '0'
# Looks like you failed 1 test of 1.


-- 
Bill Moseley
mose...@hank.org
Sent from my iMutt

Index: t/lib/TestApp/Controller/Fork.pm
===================================================================
--- t/lib/TestApp/Controller/Fork.pm	(revision 9215)
+++ t/lib/TestApp/Controller/Fork.pm	(working copy)
@@ -58,4 +58,21 @@
     $c->response->body(Dump({pid => $pid, result => $x}));
 }
 
+
+# Test should only call if it knows IO::Pipe exist and
+# /bin/ls is available
+
+sub io_pipe : Local {
+    my ($self, $c) = @_;
+
+    eval 'require IO::Pipe' || die 'IO::Pipe failed require: ' . $@;
+
+    my $pipe = IO::Pipe->new;
+    $pipe->reader( '/bin/ls' );
+    my $line = <$pipe> || die 'Failed read from IO::Pipe handle';
+    $c->response->body( 'ok' );
+}
+
+
+
 1;
Index: t/live_fork.t
===================================================================
--- t/live_fork.t	(revision 9215)
+++ t/live_fork.t	(working copy)
@@ -23,7 +23,7 @@
 plan skip_all => 'Skipping fork tests: no /bin/ls'
     if !-e '/bin/ls'; # see if /bin/ls exists
 
-plan tests => 13; # otherwise
+plan tests => 15; # otherwise
 
 {
   system:
@@ -60,3 +60,12 @@
     isnt($result_ref->{pid}, $$, 'fork got a new pid');
     is($result_ref->{result}, 'ok', 'fork was effective');
 }
+
+SKIP: {
+  io_pipe:
+    eval 'require IO::Pipe'
+        || skip "IO::Pipe not installed", 2;
+
+    ok(my $result = get( '/fork/io_pipe'), 'io_pipe' );
+    is( $result, 'ok', 'io_pipe returned data from handle' );
+}
_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to