[Catalyst] Test server as a child process
Ivan Fomichev
ifomichev at gmail.com
Tue Jul 31 09:33:52 GMT 2007
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<------------------------script/myapp_regtest.pl--------------------------
#!/usr/bin/perl
use strict;
use warnings;
use Config::IniFiles;
use File::Spec::Functions;
use FindBin;
use POSIX qw/ :signal_h /;
my $ini = Config::IniFiles->new( -file => catfile( $FindBin::Bin,
updir, 'myapp_regtest.ini' ) );
$ENV{MYAPP_DSN} = $ini->val( 'database', 'dsn' );
defined ( my $catalyst_pid = open(CHILD, '-|') )
or die "cannot fork: $!";
if ( !$catalyst_pid ) {
my $port = $ini->val( 'catalyst', 'port' );
exec( catfile( $FindBin::Bin, 'myapp_server.pl' ), '-p', $port );
}
print scalar <CHILD>;
my $lib = catdir( $FindBin::Bin, updir, 'lib' );
chdir catdir( $FindBin::Bin, updir );
system( 'prove', '--lib', $lib, 't' );
kill SIGINT, $catalyst_pid;
8<----------------------------------END------------------------------------
Regards,
Ivan
More information about the Catalyst
mailing list