11 plan skip_all => 'set TEST_LIGHTTPD to enable this test'
12 unless $ENV{TEST_LIGHTTPD};
14 eval "use Catalyst::Devel 1.0";
15 plan skip_all => 'Catalyst::Devel required' if $@;
17 eval "use File::Copy::Recursive";
18 plan skip_all => 'File::Copy::Recursive required' if $@;
20 eval "use Test::Harness";
21 plan skip_all => 'Test::Harness required' if $@;
23 my $lighttpd_bin = $ENV{LIGHTTPD_BIN} || `which lighttpd`;
26 plan skip_all => 'Please set LIGHTTPD_BIN to the path to lighttpd'
27 unless $lighttpd_bin && -x $lighttpd_bin;
32 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
34 # create a TestApp and copy the test libs into it
35 mkdir "$FindBin::Bin/../t/tmp";
36 chdir "$FindBin::Bin/../t/tmp";
37 system "perl -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
38 chdir "$FindBin::Bin/..";
39 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
41 # remove TestApp's tests
42 rmtree 't/tmp/TestApp/t';
44 # Create a temporary lighttpd config
45 my $docroot = "$FindBin::Bin/../t/tmp";
48 # Clean up docroot path
49 $docroot =~ s{/t/..}{};
52 # basic lighttpd config file for testing fcgi+catalyst
59 server.document-root = "$docroot"
61 server.errorlog = "$docroot/error.log"
62 accesslog.filename = "$docroot/access.log"
64 server.bind = "127.0.0.1"
67 # catalyst app specific fcgi setup
71 "socket" => "$docroot/test.socket",
72 "check-local" => "disable",
73 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
82 open(my $lightconf, '>', "$docroot/lighttpd.conf")
83 or die "Can't open $docroot/lighttpd.conf: $!";
84 print {$lightconf} $conf or die "Write error: $!";
87 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
88 or die "Unable to spawn lighttpd: $!";
90 # wait for it to start
91 while ( check_port( 'localhost', $port ) != 1 ) {
92 diag "Waiting for server to start...";
96 # run the testsuite against the server
97 $ENV{CATALYST_SERVER} = "http://localhost:$port";
99 my @tests = glob('t/live_*');
103 ok(!$@, 'lighttpd tests ran OK');
110 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
113 my ( $host, $port ) = @_;
115 my $remote = IO::Socket::INET->new(