App-Prove-Plugin-Distributed
view release on metacpan or search on metacpan
lib/TAP/Parser/SourceHandler/Worker.pm view on Meta::CPAN
=head3 C<workers>
Returns list of workers.
=cut
sub workers {
return @workers;
}
=head3 C<get_active_workers>
my @active_workers = $class->get_active_workers;
Returns list of active workers.
=cut
sub get_active_workers {
my $class = shift;
my @workers = $class->workers;
return unless (@workers);
my @active;
for my $worker (@workers) {
next unless ( $worker && $worker->{sel} );
my @handles = $worker->{sel}->can_read();
for my $handle (@handles) {
if ( $handle == $worker->{err} ) {
my $error = '';
if ( $handle->read( $error, 640000 ) ) {
chomp($error);
print STDERR "Worker with error [$error].\n";
#LSF: Close the handle.
$handle->close();
$worker = undef;
last;
}
}
}
push @active, $worker if ($worker);
}
return @active;
}
=head3 C<load_options>
Setup the worker specific options.
my @active_workers = $class->load_options($app_prove_object, \@ARGV);
Returns boolean.
=cut
sub load_options {
my $class = shift;
my ( $app, $args ) = @_;
{
local @ARGV = @$args;
Getopt::Long::Configure(qw(no_ignore_case bundling pass_through));
# Don't add coderefs to GetOptions
GetOptions(
'use-local-public-ip' => \$use_local_public_ip,
'sync-test-env=s' => \$sync_type,
'destination-dir=s' => \$destination_dir
) or croak('Unable to continue');
if ($sync_type) {
if ( $sync_type eq 'rsync' ) {
require File::Rsync;
unless ($destination_dir) {
require File::Temp;
$destination_dir = File::Temp::tempdir( CLEANUP => 1 );
}
#LSF: This might not support with different directory separator.
unless ( $destination_dir =~ /\/$/ ) {
$destination_dir .= '/';
}
}
else {
die "not able to sync on the remote with type "
. $sync_type
. ".\nCurrently, only the rsync type is supported.\n";
}
}
}
return 1;
}
1;
__END__
##############################################################################
( run in 2.057 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )