Re: [Catalyst] IO::Pipe and the Catalyst Server

2009-02-26 Thread Bill Moseley
Hi Florian,

You asked for a test. Did this get applied?


On Thu, Feb 05, 2009 at 09:25:34AM -0800, Bill Moseley wrote:
> 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/


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


___
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/


Re: [Catalyst] IO::Pipe and the Catalyst Server

2009-02-05 Thread Bill Moseley
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/


Re: [Catalyst] IO::Pipe and the Catalyst Server

2009-02-05 Thread Peter Karman
Bill Moseley wrote on 02/05/2009 09:10 AM:
> On Thu, Feb 05, 2009 at 01:23:03PM +0100, Florian Ragwitz wrote:
>> On Wed, Feb 04, 2009 at 10:25:15PM -0800, Bill Moseley wrote:
>>> I have a module that uses IO::Pipe and when I run it under the
>>> Catalyst server the pipe doesn't work (see below).
>> Please try to reproduce with Catalyst-Runtime-5.8000_06. It has a fix
>> related to spawning external processes from the dev server.
> 
> $ PERL5LIB=$HOME/cur_cat script/pipe_server.pl 
> 5.8000_06
> You can connect to your server at http://bumby2:3000
> about to read from handle
> hello
> 
> Same problem.
> 
> 

is it possible this is related to how Cat can mess with STDOUT and STDIN?

I have these lines in SVN::Class:

# this trick cribbed from mst's Catalyst::Controller::WrapCGI
# we alias STDIN and STDOUT since Catalyst (and presumaly other code)
# might be messing with STDOUT or STDIN
open( *REAL_STDIN,  "<&=" . fileno(*STDIN) );
open( *REAL_STDOUT, ">>&=" . fileno(*STDOUT) );



-- 
Peter Karman  .  pe...@peknet.com  .  http://peknet.com/


___
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/


Re: [Catalyst] IO::Pipe and the Catalyst Server

2009-02-05 Thread Florian Ragwitz
On Thu, Feb 05, 2009 at 07:10:07AM -0800, Bill Moseley wrote:
> Same problem.

Would you mind preparing a testcase for this?

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.


-- 
BOFH excuse #86:
Runt packets


signature.asc
Description: Digital signature
___
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/


Re: [Catalyst] IO::Pipe and the Catalyst Server

2009-02-05 Thread Bill Moseley
On Thu, Feb 05, 2009 at 01:23:03PM +0100, Florian Ragwitz wrote:
> On Wed, Feb 04, 2009 at 10:25:15PM -0800, Bill Moseley wrote:
> > I have a module that uses IO::Pipe and when I run it under the
> > Catalyst server the pipe doesn't work (see below).
> 
> Please try to reproduce with Catalyst-Runtime-5.8000_06. It has a fix
> related to spawning external processes from the dev server.

$ PERL5LIB=$HOME/cur_cat script/pipe_server.pl 
5.8000_06
You can connect to your server at http://bumby2:3000
about to read from handle
hello

Same problem.


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


___
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/


Re: [Catalyst] IO::Pipe and the Catalyst Server

2009-02-05 Thread Florian Ragwitz
On Thu, Feb 05, 2009 at 12:51:18PM +, Peter Edwards wrote:
>Was that the change to the catching of signal SIGCHLD ?

Exactly.

-- 
BOFH excuse #66:
bit bucket overflow


signature.asc
Description: Digital signature
___
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/


Re: [Catalyst] IO::Pipe and the Catalyst Server

2009-02-05 Thread Peter Edwards
>
> 2009/2/5 Florian Ragwitz 
>
>> On Wed, Feb 04, 2009 at 10:25:15PM -0800, Bill Moseley wrote:
>> > I have a module that uses IO::Pipe and when I run it under the
>> > Catalyst server the pipe doesn't work (see below).
>>
>> Please try to reproduce with Catalyst-Runtime-5.8000_06. It has a fix
>> related to spawning external processes from the dev server.
>>
>
Was that the change to the catching of signal SIGCHLD ?I've been meaning to
try that out too.

Thanks, Peter
___
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/


Re: [Catalyst] IO::Pipe and the Catalyst Server

2009-02-05 Thread Florian Ragwitz
On Wed, Feb 04, 2009 at 10:25:15PM -0800, Bill Moseley wrote:
> I have a module that uses IO::Pipe and when I run it under the
> Catalyst server the pipe doesn't work (see below).

Please try to reproduce with Catalyst-Runtime-5.8000_06. It has a fix
related to spawning external processes from the dev server.


-- 
BOFH excuse #311:
transient bus protocol violation


signature.asc
Description: Digital signature
___
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/