6 plan skip_all => 'set TEST_LIGHTTPD to enable this test'
7 unless $ENV{TEST_LIGHTTPD};
16 plan skip_all => 'FCGI required' if $@;
18 eval "use Catalyst::Devel 1.0";
19 plan skip_all => 'Catalyst::Devel required' if $@;
21 eval "use File::Copy::Recursive";
22 plan skip_all => 'File::Copy::Recursive required' if $@;
24 eval "use Test::Harness";
25 plan skip_all => 'Test::Harness required' if $@;
27 my $lighttpd_bin = $ENV{LIGHTTPD_BIN} || `which lighttpd`;
30 plan skip_all => 'Please set LIGHTTPD_BIN to the path to lighttpd'
31 unless $lighttpd_bin && -x $lighttpd_bin;
36 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
38 # create a TestApp and copy the test libs into it
39 mkdir "$FindBin::Bin/../t/tmp";
40 chdir "$FindBin::Bin/../t/tmp";
41 system "$^X -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
42 chdir "$FindBin::Bin/..";
43 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
45 # remove TestApp's tests
46 rmtree 't/tmp/TestApp/t';
48 # Create a temporary lighttpd config
49 my $docroot = "$FindBin::Bin/../t/tmp";
52 # Clean up docroot path
53 $docroot =~ s{/t/\.\.}{};
55 my $perl5lib = join($Config::Config{path_sep}, "$docroot/../../lib", $ENV{PERL5LIB} || ());
58 # basic lighttpd config file for testing fcgi+catalyst
65 server.document-root = "$docroot"
67 server.errorlog = "$docroot/error.log"
68 accesslog.filename = "$docroot/access.log"
70 server.bind = "127.0.0.1"
73 # catalyst app specific fcgi setup
77 "socket" => "$docroot/test.socket",
78 "check-local" => "disable",
79 "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(