Plient/Test.pm

filter: Statementstmt 73.1% 30 / 41 Branchbran 16.6% 1 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 67.2% 41 / 61 CC 5 SCAR 20.9
CC
5
Cov
63%
start_http_server
20.7
BEGIN
1.0
BEGIN
1.0
CRAP 8.1
« Plient/Protocol.pm ↑ Summary Plient/Util.pm »
1 package Plient::Test;
2  
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Plient::Util 'which';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Time::HiRes 'usleep';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use File::Spec::Functions;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use FindBin '$Bin';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 our @EXPORT = qw/start_http_server/;
13 4 my @pids;
14  
15 3 ▶sub start_http_server {
Subroutine start_http_server: called CC=5 SCAR=30.3
Pod undocumented
16 3 my $plackup = which('plackup');
17 3 ▶ return unless $plackup;
Branch: 1 branch
BranchTrueFalseTotal
unless $plackup 3 0 3
18  
19 0 my $psgi = catfile( $Bin, 'app.psgi' );
20 0 my $port = 5000 + int(rand(1000));
21 0 my $pid = fork;
22 0 ▶ if ( defined $pid ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pid) { } 0 0 0
23 0 ▶ if ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid) { } 0 0 0
24 # have you ever been annoied that "sleep 1" is too much?
25 0 ▶ usleep 1_000_000 * ( $ENV{PLIENT_TEST_PLACKUP_WAIT} || 1 );
Condition0%0/2
$ENV{'PLIENT_TEST_PLACKUP_WAIT'} || 1
l!l
00
MC/DC0%0/1
$ENV{'PLIENT_TEST_PLACKUP_WAIT'} || 1
$ENV{'PLIENT_TEST_PLACKUP_WAIT'}
Truth table0%0/2
A
A= $ENV{'PLIENT_TEST_PLACKUP_WAIT'}
Aresult
11
00
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 4 ▶END {
Subroutine END: called CC=1 SCAR=0.0
40 4 kill TERM => @pids;
41 }
42  
43 4 1;
44  
45 __END__
« Plient/Protocol.pm ↑ Summary Plient/Util.pm »