8 plan skip_all => 'set TEST_LIGHTTPD to enable this test'
9 unless $ENV{TEST_LIGHTTPD};
17 plan skip_all => 'FCGI required' if $@;
19 eval "use Catalyst::Devel 1.0";
20 plan skip_all => 'Catalyst::Devel required' if $@;
22 eval "use File::Copy::Recursive";
23 plan skip_all => 'File::Copy::Recursive required' if $@;
25 eval "use Test::Harness";
26 plan skip_all => 'Test::Harness required' if $@;
28 my $lighttpd_bin = $ENV{LIGHTTPD_BIN} || `which lighttpd`;
31 plan skip_all => 'Please set LIGHTTPD_BIN to the path to lighttpd'
32 unless $lighttpd_bin && -x $lighttpd_bin;
37 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
39 # create a TestApp and copy the test libs into it
40 mkdir "$FindBin::Bin/../t/tmp";
41 chdir "$FindBin::Bin/../t/tmp";
42 system "$^X -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
43 chdir "$FindBin::Bin/..";
44 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
46 # remove TestApp's tests
47 rmtree 't/tmp/TestApp/t';
49 # Create a temporary lighttpd config
50 my $docroot = "$FindBin::Bin/../t/tmp";
53 # Clean up docroot path
54 $docroot =~ s{/t/..}{};
57 # basic lighttpd config file for testing fcgi+catalyst
65 server.document-root = "$docroot"
67 server.errorlog = "$docroot/error.log"
68 accesslog.filename = "$docroot/access.log"
70 server.bind = "127.0.0.1"
73 # Work around inability to hit http://localhost/deep/path
74 # without a trailing slash
75 url.rewrite = ( "deep/path\$" => "deep/path/" )
77 # catalyst app specific fcgi setup
81 "socket" => "$docroot/test.socket",
82 "check-local" => "disable",
83 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
87 "bin-environment" => (
88 "PERL5LIB" => "$docroot/../../lib"
95 open(my $lightconf, '>', "$docroot/lighttpd.conf")
96 or die "Can't open $docroot/lighttpd.conf: $!";
97 print {$lightconf} $conf or die "Write error: $!";
100 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
101 or die "Unable to spawn lighttpd: $!";
103 # wait for it to start
104 while ( check_port( 'localhost', $port ) != 1 ) {
105 diag "Waiting for server to start...";
109 # run the testsuite against the server
110 $ENV{CATALYST_SERVER} = "http://localhost:$port/deep/path";
112 my @tests = (shift) || glob('t/aggregate/live_*');
116 ok(!$@, 'lighttpd tests ran OK');
123 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
126 my ( $host, $port ) = @_;
128 my $remote = IO::Socket::INET->new(