chmod -x test scripts
[catagits/Catalyst-Runtime.git] / t / optional_apache-fastcgi.pl
CommitLineData
58f5682a 1# Run all tests against FastCGI mode under Apache
2#
3# Note, to get this to run properly, you may need to give it the path to your
4# httpd.conf:
50cc3183 5#
55a7d985 6# perl t/optional_apache-fastcgi.pl -httpd_conf /etc/apache/httpd.conf
58f5682a 7
8use strict;
9use warnings;
10
11use Apache::Test;
12use Apache::TestRun ();
13
14use File::Path;
15use File::Copy::Recursive;
16use FindBin;
e2a24892 17use IO::Socket;
58f5682a 18
19# clean up
50cc3183 20rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
58f5682a 21
22# create a TestApp and copy the test libs into it
50cc3183 23mkdir "$FindBin::Bin/../t/tmp";
24chdir "$FindBin::Bin/../t/tmp";
25system "$FindBin::Bin/../script/catalyst.pl TestApp";
26chdir "$FindBin::Bin/..";
27File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
58f5682a 28
29# remove TestApp's tests so Apache::Test doesn't try to run them
10bdcbe8 30rmtree 't/tmp/TestApp/t';
58f5682a 31
62fdfd9c 32$ENV{CATALYST_SERVER} = 'http://localhost:8529';
33
55a7d985 34if ( !-e 't/optional_apache-fastcgi.pl' ) {
62fdfd9c 35 die "ERROR: Please run test from the Catalyst-Runtime directory\n";
36}
37
a68314c2 38push @ARGV, glob( 't/aggregate/live_*' );
58f5682a 39
40Apache::TestRun->new->run(@ARGV);
41
e2a24892 42# clean up if the server has shut down
43# this allows the test files to stay around if the user ran -start-httpd
50cc3183 44if ( !check_port( 'localhost', 8529 ) ) {
45 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
e2a24892 46}
47
48sub check_port {
49 my ( $host, $port ) = @_;
50
51 my $remote = IO::Socket::INET->new(
52 Proto => "tcp",
53 PeerAddr => $host,
54 PeerPort => $port
55 );
56 if ($remote) {
57 close $remote;
58 return 1;
59 }
60 else {
61 return 0;
62 }
63}