9 eval "use Catalyst::Devel 1.0";
10 plan skip_all => 'Catalyst::Devel required' if $@;
12 eval "use File::Copy::Recursive";
13 plan skip_all => 'File::Copy::Recursive required' if $@;
15 my $lighttpd_bin = $ENV{LIGHTTPD_BIN} || 'lighttpd';
16 plan skip_all => 'Cannot find lighttpd, please set LIGHTTPD_BIN'
17 unless -x $lighttpd_bin;
27 plan skip_all => 'set TEST_LIGHTTPD to enable this test'
28 unless $ENV{TEST_LIGHTTPD};
30 eval "use Catalyst::Devel 1.0";
31 plan skip_all => 'Catalyst::Devel required' if $@;
33 eval "use File::Copy::Recursive";
34 plan skip_all => 'File::Copy::Recursive required' if $@;
36 eval "use Test::Harness";
37 plan skip_all => 'Test::Harness required' if $@;
39 my $lighttpd_bin = $ENV{LIGHTTPD_BIN} || `which lighttpd`;
42 plan skip_all => 'Please set LIGHTTPD_BIN to the path to lighttpd'
43 unless $lighttpd_bin && -x $lighttpd_bin;
48 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
50 # create a TestApp and copy the test libs into it
51 mkdir "$FindBin::Bin/../t/tmp";
52 chdir "$FindBin::Bin/../t/tmp";
53 system "perl -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
54 chdir "$FindBin::Bin/..";
55 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
57 # remove TestApp's tests
58 rmtree 't/tmp/TestApp/t';
60 # Create a temporary lighttpd config
61 my $docroot = "$FindBin::Bin/../t/tmp";
64 # Clean up docroot path
65 $docroot =~ s{/t/..}{};
68 # basic lighttpd config file for testing fcgi+catalyst
75 server.document-root = "$docroot"
77 server.errorlog = "$docroot/error.log"
78 accesslog.filename = "$docroot/access.log"
80 server.bind = "127.0.0.1"
83 # catalyst app specific fcgi setup
87 "socket" => "$docroot/test.socket",
88 "check-local" => "disable",
89 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
98 open(my $lightconf, '>', "$docroot/lighttpd.conf")
99 or die "Can't open $docroot/lighttpd.conf: $!";
100 print {$lightconf} $conf or die "Write error: $!";
103 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
104 or die "Unable to spawn lighttpd: $!";
106 # wait for it to start
107 while ( check_port( 'localhost', $port ) != 1 ) {
108 diag "Waiting for server to start...";
112 # run the testsuite against the server
113 $ENV{CATALYST_SERVER} = "http://localhost:$port/deep/path";
115 my @tests = glob('t/live_*');
119 ok(!$@, 'lighttpd tests ran OK');
126 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
129 my ( $host, $port ) = @_;
131 my $remote = IO::Socket::INET->new(