6 plan skip_all => 'set TEST_LIGHTTPD to enable this test'
7 unless $ENV{TEST_LIGHTTPD};
17 plan skip_all => 'FCGI required' if $@;
19 eval "use File::Copy::Recursive";
20 plan skip_all => 'File::Copy::Recursive required' if $@;
22 eval "use Test::Harness";
23 plan skip_all => 'Test::Harness required' if $@;
29 my $lighttpd_bin = $ENV{LIGHTTPD_BIN} || `which lighttpd`;
32 plan skip_all => 'Please set LIGHTTPD_BIN to the path to lighttpd'
33 unless $lighttpd_bin && -x $lighttpd_bin;
39 # Create a temporary lighttpd config
40 my $docroot = "$FindBin::Bin/../t/tmp";
43 # Clean up docroot path
44 $docroot =~ s{/t/\.\.}{};
46 my $perl5lib = join($Config::Config{path_sep}, "$docroot/../../lib", $ENV{PERL5LIB} || ());
49 # basic lighttpd config file for testing fcgi+catalyst
57 server.document-root = "$docroot"
59 server.errorlog = "$docroot/error.log"
60 accesslog.filename = "$docroot/access.log"
62 server.bind = "127.0.0.1"
65 # Work around inability to hit http://localhost/deep/path
66 # without a trailing slash
67 url.rewrite = ( "deep/path\$" => "deep/path/" )
69 # catalyst app specific fcgi setup
73 "socket" => "$docroot/test.socket",
74 "check-local" => "disable",
75 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
79 "bin-environment" => (
80 "PERL5LIB" => "$perl5lib"
87 open(my $lightconf, '>', "$docroot/lighttpd.conf")
88 or die "Can't open $docroot/lighttpd.conf: $!";
89 print {$lightconf} $conf or die "Write error: $!";
92 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
93 or die "Unable to spawn lighttpd: $!";
95 # wait for it to start
96 while ( check_port( 'localhost', $port ) != 1 ) {
97 diag "Waiting for server to start...";
101 # run the testsuite against the server
102 $ENV{CATALYST_SERVER} = "http://localhost:$port/deep/path";
104 my @tests = (shift) || glob('t/aggregate/live_*');
108 ok(!$@, 'lighttpd tests ran OK');
115 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
118 my ( $host, $port ) = @_;
120 my $remote = IO::Socket::INET->new(