Commit | Line | Data |
58f5682a |
1 | #!perl |
2 | |
3 | # Run all tests against FastCGI 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: |
50cc3183 |
7 | # |
55a7d985 |
8 | # perl t/optional_apache-fastcgi.pl -httpd_conf /etc/apache/httpd.conf |
58f5682a |
9 | |
10 | use strict; |
11 | use warnings; |
12 | |
13 | use Apache::Test; |
14 | use Apache::TestRun (); |
15 | |
16 | use File::Path; |
17 | use File::Copy::Recursive; |
18 | use FindBin; |
e2a24892 |
19 | use IO::Socket; |
58f5682a |
20 | |
21 | # clean up |
50cc3183 |
22 | rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp"; |
58f5682a |
23 | |
24 | # create a TestApp and copy the test libs into it |
50cc3183 |
25 | mkdir "$FindBin::Bin/../t/tmp"; |
26 | chdir "$FindBin::Bin/../t/tmp"; |
27 | system "$FindBin::Bin/../script/catalyst.pl TestApp"; |
28 | chdir "$FindBin::Bin/.."; |
29 | File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' ); |
58f5682a |
30 | |
31 | # remove TestApp's tests so Apache::Test doesn't try to run them |
10bdcbe8 |
32 | rmtree 't/tmp/TestApp/t'; |
58f5682a |
33 | |
62fdfd9c |
34 | $ENV{CATALYST_SERVER} = 'http://localhost:8529'; |
35 | |
55a7d985 |
36 | if ( !-e 't/optional_apache-fastcgi.pl' ) { |
62fdfd9c |
37 | die "ERROR: Please run test from the Catalyst-Runtime directory\n"; |
38 | } |
39 | |
40 | push @ARGV, glob( 't/live_*' ); |
58f5682a |
41 | |
42 | Apache::TestRun->new->run(@ARGV); |
43 | |
e2a24892 |
44 | # clean up if the server has shut down |
45 | # this allows the test files to stay around if the user ran -start-httpd |
50cc3183 |
46 | if ( !check_port( 'localhost', 8529 ) ) { |
47 | rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp"; |
e2a24892 |
48 | } |
49 | |
50 | sub 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 | } |