t/run/testprog.pl

filter: Statementstmt 100% 39 / 39 Branchbran 66.6% 12 / 18 Conditioncond 100% 5 / 5 MC/DCmcdc 100% 3 / 3 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 91.5% 65 / 71 CC 1 SCAR 0.0
CC
1
Cov
90%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/IPC/PrettyPipe/Types.pm ↑ Summary blib/lib/IPC/PrettyPipe/Arg/Format.pm »
1 #!perl
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use File::Spec::Functions qw[ catfile ];
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 8 my @fh = ( [ \*STDIN, '<' ], [ \*STDOUT, '>' ], [ \*STDERR, '>' ], );
12  
13 8 my %opt;
14  
15 8 ▶GetOptions(
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions(\%opt, ("logdir=s", "long=s", "sleep=i", "s=s", "name=s")) or die 8 0 8
16 \%opt,
17 qw[
18 logdir=s
19 long=s
20 sleep=i
21 s=s
22 name=s
23 ] ) or die;
24  
25 die( "must specify name\n" )
26 8 ▶ unless defined $opt{name};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opt{"name"} 0 8 8
27  
28 die( "must specify logdir\n" )
29 8 ▶ unless defined $opt{logdir};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opt{"logdir"} 0 8 8
30  
31 8 my %LOG = %opt;
32  
33  
34 8 ▶sleep( $opt{sleep} ) if defined $opt{sleep};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opt{"sleep"} 0 8 8
35  
36 8 ▶while ( @ARGV ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV) 26 8 34
37  
38 26 my $fd = shift @ARGV;
39  
40 my ( $fh, $mode )
41 26 ▶ = @{ $fh[$fd]
Condition100%2/2
$fh[$fd] // ["IO::Handle"->new_from_fd($fd, $ARGV[0]), shift @ARGV]
l!l
1610
MC/DC100%1/1
$fh[$fd] // ["IO::Handle"->new_from_fd($fd, $ARGV[0]), shift @ARGV]
$fh[$fd]
Truth table100%2/2
A
A= $fh[$fd]
Aresult
11
00
42 // [ IO::Handle->new_from_fd( $fd, $ARGV[0] ), shift @ARGV ] };
43  
44 26 ▶ die( "can't open $fd\n" )
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 26 26
45 unless defined $fh;
46  
47 26 ▶ if ( $mode eq '<' or $mode eq 'r' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq '<' or $mode eq 'r') { } 7 19 26
Condition100%3/3
$mode eq "<" or $mode eq "r"
l!l&&r!l&&!r
2519
MC/DC100%2/2
$mode eq "<" or $mode eq "r"
$mode eq "<" $mode eq "r"
Truth table100%3/3
A or B
A= $mode eq "<"B= $mode eq "r"
ABresult
1X1
011
000
48  
49 7 my @input = $fh->getlines;
50  
51 7 $LOG{$fd} = \@input;
52  
53 7 ▶ print STDOUT @input if $fd == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $fd == 0 2 5 7
54  
55 }
56 else {
57  
58 19 $fh->say( "$opt{name} $fd" );
59  
60 }
61  
62  
63 }
64  
65 8 my $logfile = catfile( $opt{logdir}, $opt{name} ) . ".log";
66 8 ▶open( LOG, '>', $logfile )
Branch: 1 branch
BranchTrueFalseTotal
open LOG, ">", $logfile or die "error creating $logfile\n" 8 0 8
67 or die( "error creating $logfile\n" );
68  
69 8 print LOG Dumper( \%LOG );
70  
71 8 close LOG;
« blib/lib/IPC/PrettyPipe/Types.pm ↑ Summary blib/lib/IPC/PrettyPipe/Arg/Format.pm »