Re: [Catalyst] Test server as a child process

2007-08-01 Thread Matt S Trout
On Tue, Jul 31, 2007 at 12:33:52PM +0400, Ivan Fomichev wrote:
> Hello,
> 
> I intend to write a script, that would start the test server as a
> child process and then run tests.

Why not just use Test::WWW::Mechanize::Catalyst which embeds a server instance
in the test script?

Using the test server instead is really just testing Catalyst::Engine as
well as your code, and we already have a test suite.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical DirectorWant a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/http://www.shadowcat.co.uk/ 

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Test server as a child process

2007-07-31 Thread Jason Kohles

On Jul 31, 2007, at 7:15 AM, Ivan Fomichev wrote:


2007/7/31, Peter Edwards <[EMAIL PROTECTED]>:
Try using IPC::Run. I can see the "You can connect" message when  
using it to

run scripts/myapp_server.pl (I guess it goes through ptys?)


I've found the root of the evil.
IPC::Run won't help here :-(
The pipe is not autoflushed.
If you put '$|++' in script/myapp_server.pl, everything works all  
right.

BTW, is there a way to force autoflush for a Perl script executed in a
child process, e. g. through environment variables, command line
options or whatever?

Actually, IPC::Run will help, if you tell it to use pseudo-ttys  
instead of pipes for the communication.  If perl belives it's output  
is going to a tty, then it won't buffer as it would if the output is  
a pipe.  Using Expect or IO::Pty directly, or something else that  
makes the subprocess believe it is connected to a terminal will have  
the same effect...


use IPC::Run qw( run );
run( "script/myapp_server.pl", 'pty>', $out_and_err );

--
Jason Kohles
[EMAIL PROTECTED]
http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire



___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Test server as a child process

2007-07-31 Thread Andy Grundman


On Jul 31, 2007, at 4:33 AM, Ivan Fomichev wrote:


Hello,

I intend to write a script, that would start the test server as a
child process and then run tests. The thing I'm failing to do is to
get output from the test server in order to determine, when the server
has started.

The problem is that test server doesn't print its prompt ("You can
connect to your server at http://localhost:3000";) when run as a child
process :-(

I dug Catalyst's sources, but didn't understood much. I put 'sleep' in
parent process for now, but I don't like it. Could anyone suggest an
adequate work-around? Thank you in advance.


Take a look at the core test file t/optional_http-server.t.  It does  
exactly what you are looking to do: launch the HTTP server, wait for  
it to start, run some tests, and shut it down again.  But note that  
you don't actually need to run the HTTP server in order to test your  
code.


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Test server as a child process

2007-07-31 Thread Ivan Fomichev
2007/7/31, Peter Edwards <[EMAIL PROTECTED]>:
> Try using IPC::Run. I can see the "You can connect" message when using it to
> run scripts/myapp_server.pl (I guess it goes through ptys?)

I've found the root of the evil.
IPC::Run won't help here :-(
The pipe is not autoflushed.
If you put '$|++' in script/myapp_server.pl, everything works all right.
BTW, is there a way to force autoflush for a Perl script executed in a
child process, e. g. through environment variables, command line
options or whatever?

Regards,
Ivan

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Test server as a child process

2007-07-31 Thread Jon Schutz

On Tue, 2007-07-31 at 12:33 +0400, Ivan Fomichev wrote:
> Hello,
> 
> I intend to write a script, that would start the test server as a
> child process and then run tests. The thing I'm failing to do is to
> get output from the test server in order to determine, when the server
> has started.
> 
> The problem is that test server doesn't print its prompt ("You can
> connect to your server at http://localhost:3000";) when run as a child
> process :-(
> 
> I dug Catalyst's sources, but didn't understood much. I put 'sleep' in
> parent process for now, but I don't like it. Could anyone suggest an
> adequate work-around? Thank you in advance.
> 
> 8