11 eval "use Catalyst::Devel 1.0";
12 plan skip_all => 'Catalyst::Devel required' if $@;
14 eval "use File::Copy::Recursive";
15 plan skip_all => 'File::Copy::Recursive required' if $@;
17 my $lighttpd_bin = $ENV{LIGHTTPD_BIN};
18 plan skip_all => 'Please set LIGHTTPD_BIN to run this test'
19 unless $lighttpd_bin && -x $lighttpd_bin;
24 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
26 # create a TestApp and copy the test libs into it
27 mkdir "$FindBin::Bin/../t/tmp";
28 chdir "$FindBin::Bin/../t/tmp";
29 system "perl -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
30 chdir "$FindBin::Bin/..";
31 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
33 # remove TestApp's tests
34 rmtree 't/tmp/TestApp/t';
36 # Create a temporary lighttpd config
37 my $docroot = "$FindBin::Bin/../t/tmp";
40 # Clean up docroot path
41 $docroot =~ s{/t/..}{};
44 # basic lighttpd config file for testing fcgi+catalyst
51 server.document-root = "$docroot"
53 server.errorlog = "$docroot/error.log"
54 accesslog.filename = "$docroot/access.log"
56 server.bind = "127.0.0.1"
59 # catalyst app specific fcgi setup
63 "socket" => "$docroot/test.socket",
64 "check-local" => "disable",
65 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
74 open(my $lightconf, '>', "$docroot/lighttpd.conf") or die "Can't open $docroot/lighttpd.conf: $!";
75 print {$lightconf} $conf or die "Write error: $!";
78 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
79 or die "Unable to spawn lighttpd: $!";
81 # wait for it to start
82 print "Waiting for server to start...\n";
83 while ( check_port( 'localhost', $port ) != 1 ) {
87 # run the testsuite against the server
88 $ENV{CATALYST_SERVER} = "http://localhost:$port/deep/path";
89 system( 'prove -r -Ilib/ t/live_*' );
96 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
101 my ( $host, $port ) = @_;
103 my $remote = IO::Socket::INET->new(