11 eval "use Catalyst::Devel 1.0";
12 plan skip_all => 'Catalyst::Devel required' if $@;
14 eval "use File::Copy::Recursive";
15 plan skip_all => 'File::Copy::Recursive required' if $@;
17 eval "use Test::Harness";
18 plan skip_all => 'Test::Harness required' if $@;
20 my $lighttpd_bin = $ENV{LIGHTTPD_BIN};
21 plan skip_all => 'Please set LIGHTTPD_BIN to run this test'
22 unless $lighttpd_bin && -x $lighttpd_bin;
27 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
29 # create a TestApp and copy the test libs into it
30 mkdir "$FindBin::Bin/../t/tmp";
31 chdir "$FindBin::Bin/../t/tmp";
32 system "perl -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
33 chdir "$FindBin::Bin/..";
34 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
36 # remove TestApp's tests
37 rmtree 't/tmp/TestApp/t';
39 # Create a temporary lighttpd config
40 my $docroot = "$FindBin::Bin/../t/tmp";
43 # Clean up docroot path
44 $docroot =~ s{/t/..}{};
47 # basic lighttpd config file for testing fcgi+catalyst
54 server.document-root = "$docroot"
56 server.errorlog = "$docroot/error.log"
57 accesslog.filename = "$docroot/access.log"
59 server.bind = "127.0.0.1"
62 # catalyst app specific fcgi setup
66 "socket" => "$docroot/test.socket",
67 "check-local" => "disable",
68 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
77 open(my $lightconf, '>', "$docroot/lighttpd.conf")
78 or die "Can't open $docroot/lighttpd.conf: $!";
79 print {$lightconf} $conf or die "Write error: $!";
82 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
83 or die "Unable to spawn lighttpd: $!";
85 # wait for it to start
86 while ( check_port( 'localhost', $port ) != 1 ) {
87 diag "Waiting for server to start...";
91 # run the testsuite against the server
92 $ENV{CATALYST_SERVER} = "http://localhost:$port";
94 my @tests = glob('t/live_*');
98 ok(!$@, 'lighttpd tests ran OK');
105 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
108 my ( $host, $port ) = @_;
110 my $remote = IO::Socket::INET->new(