line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAP::Parser::Iterator::Worker; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
104392
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
79
|
|
4
|
2
|
|
|
2
|
|
1031
|
use Sys::Hostname; |
|
2
|
|
|
|
|
1439
|
|
|
2
|
|
|
|
|
104
|
|
5
|
2
|
|
|
2
|
|
1131
|
use IO::Socket::INET; |
|
2
|
|
|
|
|
19479
|
|
|
2
|
|
|
|
|
17
|
|
6
|
2
|
|
|
2
|
|
2485
|
use IO::Select; |
|
2
|
|
|
|
|
1891
|
|
|
2
|
|
|
|
|
75
|
|
7
|
2
|
|
|
2
|
|
12
|
use Cwd; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
144
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1200
|
use TAP::Parser::Iterator::Process (); |
|
2
|
|
|
|
|
17181
|
|
|
2
|
|
|
|
|
55
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
14
|
use vars qw($VERSION @ISA); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1281
|
|
12
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
|
$VERSION = '0.08'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head3 C |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Make a new worker. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _initialize { |
39
|
2
|
|
|
2
|
|
5840
|
my ( $self, $args ) = @_; |
40
|
2
|
50
|
|
|
|
14
|
return unless ( $args->{spec} ); |
41
|
2
|
|
|
|
|
24
|
$self->{spec} = $args->{spec}; |
42
|
2
|
|
|
|
|
8
|
$self->{start_up} = $args->{start_up}; |
43
|
2
|
|
|
|
|
7
|
$self->{tear_down} = $args->{tear_down}; |
44
|
2
|
|
|
|
|
6
|
$self->{error_log} = $args->{error_log}; |
45
|
2
|
|
|
|
|
7
|
$self->{switches} = $args->{switches}; |
46
|
2
|
|
|
|
|
6
|
$self->{detach} = $args->{detach}; |
47
|
2
|
|
|
|
|
6
|
$self->{test_args} = $args->{test_args}; |
48
|
2
|
|
|
|
|
9
|
$self->{sync_type} = $args->{sync_type}; |
49
|
2
|
|
|
|
|
6
|
$self->{source_dir} = $args->{source_dir}; |
50
|
2
|
|
|
|
|
5
|
$self->{destination_dir} = $args->{destination_dir}; |
51
|
|
|
|
|
|
|
return |
52
|
|
|
|
|
|
|
unless ( |
53
|
2
|
50
|
|
|
|
11
|
$self->SUPER::_initialize( |
54
|
|
|
|
|
|
|
{ command => [ $self->initialize_worker_command->[0] ] } |
55
|
|
|
|
|
|
|
) |
56
|
|
|
|
|
|
|
); |
57
|
2
|
|
|
|
|
25258
|
return $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head3 C |
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
|
|
|
|
|
|
|
sub initialize_worker_command { |
69
|
2
|
|
|
2
|
1
|
13
|
my $self = shift; |
70
|
2
|
50
|
|
|
|
16
|
if (@_) { |
71
|
0
|
|
|
|
|
0
|
$self->{initialize_worker_command} = shift; |
72
|
|
|
|
|
|
|
} |
73
|
2
|
50
|
|
|
|
13
|
unless ( $self->{initialize_worker_command} ) { |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#LSF: Get hostname and port. |
76
|
2
|
|
|
|
|
12
|
my @args = ( '--manager=' . $self->{spec} ); |
77
|
2
|
|
|
|
|
5
|
my $type = ref($self); |
78
|
2
|
|
|
|
|
5
|
my $package = __PACKAGE__; |
79
|
2
|
|
|
|
|
36
|
$type =~ s/^$package//; |
80
|
2
|
|
|
|
|
5
|
$type =~ s/::/-/g; |
81
|
2
|
50
|
33
|
|
|
14
|
if ( $self->{sync_type} && !$self->{source_dir} ) { |
82
|
0
|
|
|
|
|
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
|
|
|
|
|
0
|
$self->{source_dir} = $cwd . '/'; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#my $option_name = '--worker' . ( $type ? '-' . lc($type) : '' ) . '-option'; |
90
|
2
|
|
|
|
|
24
|
my $option_name = '--worker-option'; |
91
|
2
|
|
|
|
|
9
|
for my $option ( |
92
|
|
|
|
|
|
|
qw(start_up tear_down error_log detach sync_type source_dir destination_dir) |
93
|
|
|
|
|
|
|
) |
94
|
|
|
|
|
|
|
{ |
95
|
14
|
|
|
|
|
22
|
my $name = $option; |
96
|
14
|
|
|
|
|
35
|
$name =~ s/_/-/g; |
97
|
14
|
50
|
66
|
|
|
51
|
if ( $option eq 'detach' && $self->{$option} ) { |
98
|
0
|
|
|
|
|
0
|
push @args, "--$name"; |
99
|
0
|
|
|
|
|
0
|
next; |
100
|
|
|
|
|
|
|
} |
101
|
14
|
50
|
|
|
|
43
|
push @args, "--$name=" . $self->{$option} if ( $self->{$option} ); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
#LSF: Find the library path. |
105
|
2
|
|
|
|
|
5
|
my $path; |
106
|
2
|
|
|
|
|
11
|
$package =~ s/::/\//g; |
107
|
2
|
|
|
|
|
4
|
$package .= '.pm'; |
108
|
2
|
50
|
|
|
|
13
|
if ( $INC{$package} ) { |
109
|
2
|
|
|
|
|
6
|
$path = $INC{$package}; |
110
|
2
|
|
|
|
|
34
|
$path =~ s/$package//; |
111
|
|
|
|
|
|
|
} |
112
|
2
|
|
|
|
|
6
|
my $switches = ''; |
113
|
2
|
50
|
|
|
|
11
|
if ( $self->{switches} ) { |
114
|
0
|
|
|
|
|
0
|
$switches = join ' ', @{ $self->{switches} }; |
|
0
|
|
|
|
|
0
|
|
115
|
|
|
|
|
|
|
} |
116
|
2
|
|
|
|
|
191
|
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
|
|
|
|
|
0
|
$self->{test_args} && @{ $self->{test_args} } |
122
|
2
|
50
|
33
|
|
|
32
|
? ' :: ' . ( join ' ', @{ $self->{test_args} } ) |
123
|
|
|
|
|
|
|
: '' |
124
|
|
|
|
|
|
|
) |
125
|
|
|
|
|
|
|
]; |
126
|
|
|
|
|
|
|
} |
127
|
2
|
|
|
|
|
39
|
return $self->{initialize_worker_command}; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
__END__ |