Merge pull request #170 from perl-catalyst/haarg/no-dev-circ-deps
[catagits/Catalyst-Runtime.git] / t / optional_apache-cgi.pl
CommitLineData
58f5682a 1# Run all tests against CGI 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#
130ebb11 6# perl t/optional_apache-cgi.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
8ae46e98 19use lib 't/lib';
20use MakeTestApp;
21
22make_test_app;
58f5682a 23
dd3af04e 24$ENV{CATALYST_SERVER} = 'http://localhost:8529/cgi';
58f5682a 25
498a0db3 26if ( !-e 't/optional_apache-cgi.pl' ) {
27 die "ERROR: Please run test from the Catalyst-Runtime directory\n";
28}
29
a68314c2 30push @ARGV, glob( 't/aggregate/live_*' );
498a0db3 31
58f5682a 32Apache::TestRun->new->run(@ARGV);
33
e2a24892 34# clean up if the server has shut down
35# this allows the test files to stay around if the user ran -start-httpd
50cc3183 36if ( !check_port( 'localhost', 8529 ) ) {
37 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
e2a24892 38}
39
40sub check_port {
41 my ( $host, $port ) = @_;
42
43 my $remote = IO::Socket::INET->new(
44 Proto => "tcp",
45 PeerAddr => $host,
46 PeerPort => $port
47 );
48 if ($remote) {
49 close $remote;
50 return 1;
51 }
52 else {
53 return 0;
54 }
55}