10 use Catalyst
::ScriptRunner
;
13 use SGN
::Devel
::MyDevLibs
;
16 "carpalways" => \
( my $carpalways = 0 ),
19 require Carp
::Always
if $carpalways;
21 my @prove_args = @ARGV;
22 @prove_args = ( 't' ) unless @prove_args;
24 my $parallel = (grep /^-j\d*$/, @ARGV) ?
1 : 0;
26 $ENV{SGN_CONFIG_LOCAL_SUFFIX
} = 'testing';
28 my $server_pid = fork;
29 unless( $server_pid ) {
32 $ENV{SGN_TEST_MODE
} = 1;
35 ( $parallel ?
('--fork') : () ),
37 Catalyst
::ScriptRunner
->run('SGN', 'Server');
40 warn "$0: starting web server with PID $server_pid.\n";
42 # wait for the test server to start
44 local $SIG{CHLD
} = sub {
45 waitpid $server_pid, 0;
46 die "\nTest server failed to start. Aborting.\n";
48 sleep 1 until !kill(0, $server_pid) || get
'http://localhost:3003';
52 unless( $prove_pid ) {
53 # test harness process
56 # set up env vars for prove and the tests
57 $ENV{SGN_TEST_SERVER
} = 'http://localhost:3003';
59 $ENV{SGN_PARALLEL_TESTING
} = 1;
60 $ENV{SGN_SKIP_LEAK_TEST
} = 1;
63 # now run the tests against it
64 my $app = App
::Prove
->new;
67 ( map { -I
=> $_ } @INC ),
70 exit( $app->run ?
0 : 1 );
73 $SIG{CHLD
} = 'IGNORE';
74 $SIG{INT
} = sub { kill 15, $server_pid, $prove_pid };
75 $SIG{KILL
} = sub { kill 9, $server_pid, $prove_pid };
77 warn "$0: prove started with PID $prove_pid.\n";
78 waitpid $prove_pid, 0;
79 warn "$0: prove finished, stopping web server PID $server_pid.\n";
80 END { kill 15, $server_pid if $server_pid }
81 waitpid $server_pid, 0;
87 test_all.pl - start a dev server and run tests against it
91 t/test_all.pl --carpalways -- -v -j5 t/mytest.t t/mydiroftests/
95 --carpalways Load Carp::Always in both the server and the test process
96 to force backtraces of all warnings and errors