line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plient::Test; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2907
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
131
|
|
4
|
4
|
|
|
4
|
|
29
|
use strict; |
|
4
|
|
|
|
|
31
|
|
|
4
|
|
|
|
|
117
|
|
5
|
4
|
|
|
4
|
|
20
|
use Carp; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
257
|
|
6
|
4
|
|
|
4
|
|
2228
|
use Plient::Util 'which'; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
338
|
|
7
|
4
|
|
|
4
|
|
15438
|
use Time::HiRes 'usleep'; |
|
4
|
|
|
|
|
11022
|
|
|
4
|
|
|
|
|
24
|
|
8
|
4
|
|
|
4
|
|
7907
|
use File::Spec::Functions; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
476
|
|
9
|
4
|
|
|
4
|
|
4243
|
use FindBin '$Bin'; |
|
4
|
|
|
|
|
6206
|
|
|
4
|
|
|
|
|
721
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
30
|
use base 'Exporter'; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
1858
|
|
12
|
|
|
|
|
|
|
our @EXPORT = qw/start_http_server/; |
13
|
|
|
|
|
|
|
my @pids; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub start_http_server { |
16
|
3
|
|
|
3
|
0
|
66
|
my $plackup = which('plackup'); |
17
|
3
|
50
|
|
|
|
17
|
return unless $plackup; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $psgi = catfile( $Bin, 'app.psgi' ); |
20
|
0
|
|
|
|
|
|
my $port = 5000 + int(rand(1000)); |
21
|
0
|
|
|
|
|
|
my $pid = fork; |
22
|
0
|
0
|
|
|
|
|
if ( defined $pid ) { |
23
|
0
|
0
|
|
|
|
|
if ($pid) { |
24
|
|
|
|
|
|
|
# have you ever been annoied that "sleep 1" is too much? |
25
|
0
|
|
0
|
|
|
|
usleep 1_000_000 * ( $ENV{PLIENT_TEST_PLACKUP_WAIT} || 1 ); |
26
|
0
|
|
|
|
|
|
push @pids, $pid; |
27
|
0
|
|
|
|
|
|
return "http://localhost:$port"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else { |
30
|
0
|
|
|
|
|
|
exec "plackup --port $port -E deployment $psgi"; |
31
|
0
|
|
|
|
|
|
exit; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else { |
35
|
0
|
|
|
|
|
|
die "fork server failed"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
END { |
40
|
4
|
|
|
4
|
|
6221
|
kill TERM => @pids; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |