7 use File::Slurp qw(write_file);
12 eval "use Catalyst::Devel 1.0";
13 plan skip_all => 'Catalyst::Devel required' if $@;
15 eval "use File::Copy::Recursive";
16 plan skip_all => 'File::Copy::Recursive required' if $@;
18 my $lighttpd_bin = $ENV{LIGHTTPD_BIN};
19 plan skip_all => 'Please set LIGHTTPD_BIN to run this test'
20 unless $lighttpd_bin && -x $lighttpd_bin;
27 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
29 # create a TestApp and copy the test libs into it
30 mkdir "$FindBin::Bin/../t/tmp";
31 chdir "$FindBin::Bin/../t/tmp";
32 system "perl -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
33 chdir "$FindBin::Bin/..";
34 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
36 # remove TestApp's tests
37 rmtree 't/tmp/TestApp/t';
39 # Create a temporary lighttpd config
40 my $docroot = "$FindBin::Bin/../t/tmp";
43 # Clean up docroot path
44 $docroot =~ s{/t/..}{};
47 # basic lighttpd config file for testing fcgi+catalyst
54 server.document-root = "$docroot"
56 server.errorlog = "$docroot/error.log"
57 accesslog.filename = "$docroot/access.log"
59 server.bind = "127.0.0.1"
62 # catalyst app specific fcgi setup
66 "socket" => "$docroot/test.socket",
67 "check-local" => "disable",
68 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
77 File::Slurp::write_file( "$docroot/lighttpd.conf", $conf );
79 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
80 or die "Unable to spawn lighttpd: $!";
82 # wait for it to start
83 print "Waiting for server to start...\n";
84 while ( check_port( 'localhost', $port ) != 1 ) {
88 # run the testsuite against the server
89 $ENV{CATALYST_SERVER} = "http://localhost:$port/deep/path";
90 system( 'prove -r -Ilib/ t/live_*' );
97 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
102 my ( $host, $port ) = @_;
104 my $remote = IO::Socket::INET->new(