6 plan skip_all => 'set TEST_LIGHTTPD to enable this test'
7 unless $ENV{TEST_LIGHTTPD};
15 plan skip_all => 'FCGI required' if $@;
17 eval "use Catalyst::Devel 1.0";
18 plan skip_all => 'Catalyst::Devel required' if $@;
20 eval "use File::Copy::Recursive";
21 plan skip_all => 'File::Copy::Recursive required' if $@;
23 eval "use Test::Harness";
24 plan skip_all => 'Test::Harness required' if $@;
26 my $lighttpd_bin = $ENV{LIGHTTPD_BIN} || `which lighttpd`;
29 plan skip_all => 'Please set LIGHTTPD_BIN to the path to lighttpd'
30 unless $lighttpd_bin && -x $lighttpd_bin;
35 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
37 # create a TestApp and copy the test libs into it
38 mkdir "$FindBin::Bin/../t/tmp";
39 chdir "$FindBin::Bin/../t/tmp";
40 system "$^X -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
41 chdir "$FindBin::Bin/..";
42 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
44 # remove TestApp's tests
45 rmtree 't/tmp/TestApp/t';
47 # Create a temporary lighttpd config
48 my $docroot = "$FindBin::Bin/../t/tmp";
51 # Clean up docroot path
52 $docroot =~ s{/t/..}{};
55 # basic lighttpd config file for testing fcgi+catalyst
62 server.document-root = "$docroot"
64 server.errorlog = "$docroot/error.log"
65 accesslog.filename = "$docroot/access.log"
67 server.bind = "127.0.0.1"
70 # catalyst app specific fcgi setup
74 "socket" => "$docroot/test.socket",
75 "check-local" => "disable",
76 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
80 "bin-environment" => (
81 "PERL5LIB" => "$docroot/../../lib"
88 open(my $lightconf, '>', "$docroot/lighttpd.conf")
89 or die "Can't open $docroot/lighttpd.conf: $!";
90 print {$lightconf} $conf or die "Write error: $!";
93 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
94 or die "Unable to spawn lighttpd: $!";
96 # wait for it to start
97 while ( check_port( 'localhost', $port ) != 1 ) {
98 diag "Waiting for server to start...";
102 # run the testsuite against the server
103 $ENV{CATALYST_SERVER} = "http://localhost:$port";
105 my @tests = (shift) || glob('t/aggregate/live_*');
109 ok(!$@, 'lighttpd tests ran OK');
116 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
119 my ( $host, $port ) = @_;
121 my $remote = IO::Socket::INET->new(