convert test checking middleware set in config to setting middleware in plugin
[catagits/Catalyst-Runtime.git] / t / optional_apache-fastcgi-non-root.pl
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:
5 #
6 # perl t/optional_apache-fastcgi-non-root.pl -httpd_conf /etc/apache/httpd.conf
7
8 use strict;
9 use warnings;
10
11 use Apache::Test;
12 use Apache::TestRun ();
13
14 use File::Path;
15 use File::Copy::Recursive;
16 use FindBin;
17 use IO::Socket;
18
19 use lib 't/lib';
20 use MakeTestApp;
21
22 make_test_app;
23
24 $ENV{CATALYST_SERVER} = 'http://localhost:8529/fastcgi/deep/path';
25
26 if ( !-e 't/optional_apache-fastcgi.pl' ) {
27     die "ERROR: Please run test from the Catalyst-Runtime directory\n";
28 }
29
30 push @ARGV, glob( 't/aggregate/live_*' );
31
32 Apache::TestRun->new->run(@ARGV);
33
34 # clean up if the server has shut down
35 # this allows the test files to stay around if the user ran -start-httpd
36 if ( !check_port( 'localhost', 8529 ) ) {
37     rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
38 }
39
40 sub 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 }