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