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
63 server.document-root = "$docroot"
65 server.errorlog = "$docroot/error.log"
66 accesslog.filename = "$docroot/access.log"
68 server.bind = "127.0.0.1"
71 # Work around inability to hit http://localhost/deep/path
72 # without a trailing slash
73 url.rewrite = ( "deep/path\$" => "deep/path/" )
75 # catalyst app specific fcgi setup
79 "socket" => "$docroot/test.socket",
80 "check-local" => "disable",
81 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
85 "bin-environment" => (
86 "PERL5LIB" => "$docroot/../../lib"
93 open(my $lightconf, '>', "$docroot/lighttpd.conf")
94 or die "Can't open $docroot/lighttpd.conf: $!";
95 print {$lightconf} $conf or die "Write error: $!";
98 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
99 or die "Unable to spawn lighttpd: $!";
101 # wait for it to start
102 while ( check_port( 'localhost', $port ) != 1 ) {
103 diag "Waiting for server to start...";
107 # run the testsuite against the server
108 $ENV{CATALYST_SERVER} = "http://localhost:$port/deep/path";
110 my @tests = (shift) || glob('t/aggregate/live_*');
114 ok(!$@, 'lighttpd tests ran OK');
121 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
124 my ( $host, $port ) = @_;
126 my $remote = IO::Socket::INET->new(