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};
24 plan skip_all => 'Please set LIGHTTPD_BIN to the path to lighttpd'
25 unless $lighttpd_bin && -x $lighttpd_bin;
30 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
32 # create a TestApp and copy the test libs into it
33 mkdir "$FindBin::Bin/../t/tmp";
34 chdir "$FindBin::Bin/../t/tmp";
35 system "perl -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
36 chdir "$FindBin::Bin/..";
37 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
39 # remove TestApp's tests
40 rmtree 't/tmp/TestApp/t';
42 # Create a temporary lighttpd config
43 my $docroot = "$FindBin::Bin/../t/tmp";
46 # Clean up docroot path
47 $docroot =~ s{/t/..}{};
50 # 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 # catalyst app specific fcgi setup
69 "socket" => "$docroot/test.socket",
70 "check-local" => "disable",
71 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
80 open(my $lightconf, '>', "$docroot/lighttpd.conf")
81 or die "Can't open $docroot/lighttpd.conf: $!";
82 print {$lightconf} $conf or die "Write error: $!";
85 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
86 or die "Unable to spawn lighttpd: $!";
88 # wait for it to start
89 while ( check_port( 'localhost', $port ) != 1 ) {
90 diag "Waiting for server to start...";
94 # run the testsuite against the server
95 $ENV{CATALYST_SERVER} = "http://localhost:$port/deep/path";
97 my @tests = glob('t/live_*');
101 ok(!$@, 'lighttpd tests ran OK');
108 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
111 my ( $host, $port ) = @_;
113 my $remote = IO::Socket::INET->new(