7 use File::Slurp qw(write_file);
12 eval "use Catalyst::Devel 1.0";
13 plan skip_all => 'Catalyst::Devel required' if $@;
15 eval "use File::Copy::Recursive";
16 plan skip_all => 'File::Copy::Recursive required' if $@;
18 my $lighttpd_bin = $ENV{LIGHTTPD_BIN} || 'lighttpd';
19 plan skip_all => 'Cannot find lighttpd, please set LIGHTTPD_BIN'
20 unless -x $lighttpd_bin;
25 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
27 # create a TestApp and copy the test libs into it
28 mkdir "$FindBin::Bin/../t/tmp";
29 chdir "$FindBin::Bin/../t/tmp";
30 system "perl -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
31 chdir "$FindBin::Bin/..";
32 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
34 # remove TestApp's tests
35 rmtree 't/tmp/TestApp/t';
37 # Create a temporary lighttpd config
38 my $docroot = "$FindBin::Bin/../t/tmp";
41 # Clean up docroot path
42 $docroot =~ s{/t/..}{};
45 # basic lighttpd config file for testing fcgi+catalyst
52 server.document-root = "$docroot"
54 server.errorlog = "$docroot/error.log"
55 accesslog.filename = "$docroot/access.log"
57 server.bind = "127.0.0.1"
60 # catalyst app specific fcgi setup
64 "socket" => "$docroot/test.socket",
65 "check-local" => "disable",
66 "bin-path" => "$docroot/TestApp/script/testapp_fastcgi.pl",
75 write_file "$docroot/lighttpd.conf", $conf;
77 my $pid = open my $lighttpd, "$lighttpd_bin -D -f $docroot/lighttpd.conf 2>&1 |"
78 or die "Unable to spawn lighttpd: $!";
80 # wait for it to start
81 print "Waiting for server to start...\n";
82 while ( check_port( 'localhost', $port ) != 1 ) {
86 # run the testsuite against the server
87 $ENV{CATALYST_SERVER} = "http://localhost:$port";
88 system( 'prove -r -Ilib/ t/live_*' );
95 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
100 my ( $host, $port ) = @_;
102 my $remote = IO::Socket::INET->new(