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;
35 my $fix_scriptname = '';
36 if (my ($vmajor, $vminor, $vpatch) = `"$lighttpd_bin" -v` =~ /\b(\d+)\.(\d+)\.(\d+)\b/) {
37 if ($vmajor > 1 || ($vmajor == 1 && ("$vminor.$vpatch" >= 4.23))) {
38 $fix_scriptname = '"fix-root-scriptname" => "enable",';
44 # this creates t/tmp/TestApp
47 # Create a temporary lighttpd config
48 my $docroot = "$FindBin::Bin/../t/tmp";
51 # Clean up docroot path
52 $docroot =~ s{/t/\.\.}{};
54 my $perl5lib = join($Config::Config{path_sep}, "$docroot/../../lib", $ENV{PERL5LIB} || ());
57 # basic lighttpd config file for testing fcgi+catalyst
64 server.document-root = "$docroot"
66 server.errorlog = "$docroot/error.log"
67 accesslog.filename = "$docroot/access.log"
69 server.bind = "127.0.0.1"
72 # catalyst app specific fcgi setup
76 "socket" => "$docroot/test.socket",
77 "check-local" => "disable",
78 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
83 "bin-environment" => (
84 "PERL5LIB" => "$perl5lib"
91 open(my $lightconf, '>', "$docroot/lighttpd.conf")
92 or die "Can't open $docroot/lighttpd.conf: $!";
93 print {$lightconf} $conf or die "Write error: $!";
96 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
97 or die "Unable to spawn lighttpd: $!";
99 # wait for it to start
100 while ( check_port( 'localhost', $port ) != 1 ) {
101 diag "Waiting for server to start...";
105 # run the testsuite against the server
106 $ENV{CATALYST_SERVER} = "http://localhost:$port";
108 my @tests = (shift) || glob('t/aggregate/live_*');
112 ok(!$@, 'lighttpd tests ran OK');
119 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
122 my ( $host, $port ) = @_;
124 my $remote = IO::Socket::INET->new(