lib/BeamerReveal/IPC/Run.pm

filter: Statementstmt 33.3% 14 / 42 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 50.0% 1 / 2 totaltotal 28.7% 19 / 66 CC 9 SCAR 31.8
CC
9
Cov
24%
runsmart
42.0
run
20.0
BEGIN
1.0
CRAP 24.0
« lib/BeamerReveal/Log.pm ↑ Summary lib/BeamerReveal/NotesFactory.pm »
1 # -*- cperl -*-
2 # ABSTRACT: IPC::Run
3  
4  
5 package BeamerReveal::IPC::Run;
6 1 our $VERSION = '20261115.1249'; # VERSION
7  
8 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use IPC::Run qw(harness start pump finish);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use File::chdir;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 0 ▶sub run {
Subroutine run: not called CC=4 SCAR=30.0
Pod documented
17 0 my ( $cmd, $coreId, $indent, $dir, $errormessage ) = @_;
18 0 my ( $out, $err );
19  
20 0 my $logger = $BeamerReveal::Log::logger;
21
22 0 my $r;
23 0 eval {
24 0 ▶ if( defined $dir ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dir) { } 0 0 0
25 0 local $CWD = $dir;
26 0 $r = IPC::Run::run( $cmd, \undef, \$out, \$err );
27 }
28 else {
29 0 $r = IPC::Run::run( $cmd, \undef, \$out, \$err );
30 }
31 };
32
33 0 ▶ if ( !defined( $r ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $r) { } 0 0 0
34 0 $logger->fatal( "Error: $@\n" );
35 }
36 else {
37 0 ▶ if ( $r ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r) { } 0 0 0
38 0 $logger->log( $indent, "- $cmd->[0] run in thread no $coreId finished" );
39 }
40 else {
41 0 $logger->fatal( $errormessage );
42 }
43 }
44 }
45  
46 0 ▶sub runsmart {
Subroutine runsmart: not called CC=6 SCAR=37.4
Pod undocumented
47 0 my ( $cmd, $mode, $regexp, $subroutine, $coreId, $indent, $dir, $errormessage ) = @_;
48 0 my ( $in, $out, $err ) = ( '', undef, undef );
49  
50 # the stream to read the progress info from is set by $mode
51 0 ▶ my $progress = ( $mode == 2 ) ? \$err : \$out;
Branch: 1 branch
BranchTrueFalseTotal
$mode == 2 ? : 0 0 0
52  
53 # get the logger
54 0 my $logger = $BeamerReveal::Log::logger;
55  
56 # run the process until finish
57 0 ▶ local $CWD = $dir if defined( $dir );
Branch: 1 branch
BranchTrueFalseTotal
if defined $dir 0 0 0
58 0 my $h = harness $cmd, \$in, \$out, \$err;
59 0 start $h;
60 0 ▶ while( $h->pumpable ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h->pumpable) 0 0 0
61 0 pump $h;
62 0 my @matches = $$progress =~ $regexp;
63 0 ▶ if ( scalar @matches ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @matches) 0 0 0
64 0 $subroutine->( @matches );
65 0 $$progress = '';
66 }
67 }
68 0 ▶ finish $h or $logger->fatal( $errormessage );
Branch: 1 branch
BranchTrueFalseTotal
finish($h) or $logger->fatal($errormessage) 0 0 0
69 }
70  
71 1 1;
72  
73 __END__
« lib/BeamerReveal/Log.pm ↑ Summary lib/BeamerReveal/NotesFactory.pm »