blib/lib/TAP/Parser/Iterator/Worker.pm

filter: Statementstmt 87.6% 64 / 73 Branchbran 50.0% 10 / 20 Conditioncond 44.4% 4 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 74.5% 88 / 118 CC 15 SCAR 25.5
CC
15
Cov
76%
initialize_worker_command
21.3
_initialize
3.0
BEGIN
1.0
CRAP 12.8
« blib/lib/TAP/Parser/SourceHandler/Worker/SSH.pm ↑ Summary blib/lib/TAP/Parser/SourceHandler/Worker/PBS.pm »
1 package TAP::Parser::Iterator::Worker;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Sys::Hostname;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use IO::Socket::INET;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use IO::Select;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use TAP::Parser::Iterator::Process ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use vars qw($VERSION @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 @ISA = 'TAP::Parser::Iterator::Process';
13  
14 =head1 NAME
15  
16 TAP::Parser::Iterator::Worker - Iterator for worker TAP sources
17  
18 =head1 VERSION
19  
20 Version 0.08
21  
22 =cut
23  
24 2 $VERSION = '0.08';
25  
26 =head1 SYNOPSIS
27  
28 =head1 DESCRIPTION
29  
30 =head1 METHODS
31  
32 =head3 C<new>
33  
34 Make a new worker.
35  
36 =cut
37  
38 2 ▶sub _initialize {
Subroutine _initialize: called CC=3 SCAR=11.0
39 2 my ( $self, $args ) = @_;
40 2 ▶ return unless ( $args->{spec} );
Branch: 1 branch
BranchTrueFalseTotal
unless $args->{"spec"} 0 2 2
41 2 $self->{spec} = $args->{spec};
42 2 $self->{start_up} = $args->{start_up};
43 2 $self->{tear_down} = $args->{tear_down};
44 2 $self->{error_log} = $args->{error_log};
45 2 $self->{switches} = $args->{switches};
46 2 $self->{detach} = $args->{detach};
47 2 $self->{test_args} = $args->{test_args};
48 2 $self->{sync_type} = $args->{sync_type};
49 2 $self->{source_dir} = $args->{source_dir};
50 2 $self->{destination_dir} = $args->{destination_dir};
51 return
52 unless (
53 2 ▶ $self->SUPER::_initialize(
Branch: 1 branch
BranchTrueFalseTotal
unless $self->SUPER::_initialize({"command", [$self->initialize_worker_command->[0]]}) 0 2 2
54 { command => [ $self->initialize_worker_command->[0] ] }
55 )
56 );
57 2 return $self;
58 }
59  
60 =head3 C<initialize_worker_command>
61  
62 Initialize the command to be used to initialize worker.
63  
64 For your specific command, you can subclass this to put your command in this method.
65  
66 =cut
67  
68 2 ▶sub initialize_worker_command {
Subroutine initialize_worker_command: called CC=13 SCAR=30.6
Pod documented
69 2 my $self = shift;
70 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
71 0 $self->{initialize_worker_command} = shift;
72 }
73 2 ▶ unless ( $self->{initialize_worker_command} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"initialize_worker_command"}) 2 0 2
74  
75 #LSF: Get hostname and port.
76 2 my @args = ( '--manager=' . $self->{spec} );
77 2 my $type = ref($self);
78 2 my $package = __PACKAGE__;
79 2 $type =~ s/^$package//;
80 2 $type =~ s/::/-/g;
81 2 ▶ if ( $self->{sync_type} && !$self->{source_dir} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"sync_type"} and not $self->{"source_dir"}) 0 2 2
Condition33%1/3
$self->{"sync_type"} and not $self->{"source_dir"}
!ll&&!rl&&r
200
MC/DC0%0/2
$self->{"sync_type"} and not $self->{"source_dir"}
$self->{"sync_type"} not $self->{"source_dir"}
Truth table33%1/3
A and not(B)
A= $self->{"sync_type"}B= not $self->{"source_dir"}
ABresult
0X0
100
111
82 0 my $cwd = File::Spec->rel2abs('.');
83  
84 #LSF: The trailing '/' must be there for source to prevent
85 # creating the source directory at destination directory
86 0 $self->{source_dir} = $cwd . '/';
87 }
88  
89 #my $option_name = '--worker' . ( $type ? '-' . lc($type) : '' ) . '-option';
90 2 my $option_name = '--worker-option';
91 2 for my $option (
92 qw(start_up tear_down error_log detach sync_type source_dir destination_dir)
93 )
94 {
95 14 my $name = $option;
96 14 $name =~ s/_/-/g;
97 14 ▶ if ( $option eq 'detach' && $self->{$option} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($option eq "detach" and $self->{$option}) 0 14 14
Condition66%2/3
$option eq "detach" and $self->{$option}
!ll&&!rl&&r
1220
MC/DC0%0/2
$option eq "detach" and $self->{$option}
$option eq "detach" $self->{$option}
Truth table66%2/3
A and B
A= $option eq "detach"B= $self->{$option}
ABresult
0X0
100
111
98 0 push @args, "--$name";
99 0 next;
100 }
101 14 ▶ push @args, "--$name=" . $self->{$option} if ( $self->{$option} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$option} 0 14 14
102 }
103  
104 #LSF: Find the library path.
105 2 my $path;
106 2 $package =~ s/::/\//g;
107 2 $package .= '.pm';
108 2 ▶ if ( $INC{$package} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{$package}) 2 0 2
109 2 $path = $INC{$package};
110 2 $path =~ s/$package//;
111 }
112 2 my $switches = '';
113 2 ▶ if ( $self->{switches} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"switches"}) 0 2 2
114 0 $switches = join ' ', @{ $self->{switches} };
115 }
116 2 my $abs_path = Cwd::abs_path($path);
117 $self->{initialize_worker_command} = [
118 "perl -I $abs_path -S prove $switches -PDistributed='"
119 . ( join ',', @args ) . "'"
120 . (
121 0 $self->{test_args} && @{ $self->{test_args} }
122 0 ▶ ? ' :: ' . ( join ' ', @{ $self->{test_args} } )
Branch: 1 branch
BranchTrueFalseTotal
$self->{'test_args'} && @{$self->{'test_args'};} ? : 0 2 2
Condition33%1/3
$self->{"test_args"} and @{$self->{"test_args"};}
!ll&&!rl&&r
200
MC/DC0%0/2
$self->{"test_args"} and @{$self->{"test_args"};}
$self->{"test_args"} @{$self->{"test_args"};}
Truth table33%1/3
A and B
A= $self->{"test_args"}B= @{$self->{"test_args"};}
ABresult
0X0
100
111
123 : ''
124 )
125 ];
126 }
127 2 return $self->{initialize_worker_command};
128 }
129  
130 2 1;
131  
132 __END__
« blib/lib/TAP/Parser/SourceHandler/Worker/SSH.pm ↑ Summary blib/lib/TAP/Parser/SourceHandler/Worker/PBS.pm »