| 1 | package POE::Component::SmokeBox::Backend; | ||||||||||||||||||||||||||||
| 2 | 47 | $POE::Component::SmokeBox::Backend::VERSION = '0.56'; | |||||||||||||||||||||||||||
| 3 | #ABSTRACT: smoker backend to POE::Component::SmokeBox | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 47 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 47 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 47 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 47 | ▶ | use Storable; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 47 | ▶ | use File::Temp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 47 | ▶ | use File::Path qw[rmtree]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 47 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 47 | ▶ | use POSIX qw( O_CREAT O_RDWR O_RDONLY ); # for SDBM_File | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 47 | ▶ | use SDBM_File; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 47 | ▶ | use POE qw[Wheel::Run Filter::Line]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 47 | ▶ | use Digest::SHA qw[sha256_hex]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 47 | ▶ | use Regexp::Assemble; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 47 | ▶ | use Env::Sanctify; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 47 | ▶ | use Module::Pluggable search_path => 'POE::Component::SmokeBox::Backend', sub_name => 'backends', except => 'POE::Component::SmokeBox::Backend::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 47 | ▶ | use constant ON_FREEBSD => $^O =~ m!^(free|midnight|dragonfly)(bsd)?$! ? 1 : 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 47 | my $GOT_KILLFAM; | |||||||||||||||||||||||||||
| 23 | my $GOT_PTY; | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | BEGIN { | ||||||||||||||||||||||||||||
| 26 | 47 | ▶ | $GOT_KILLFAM = 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=15.0
| |||||||||||||||||||||||||||||
| 27 | 47 | eval { | |||||||||||||||||||||||||||
| 28 | 47 | require Proc::ProcessTable; | |||||||||||||||||||||||||||
| 29 | 0 | $GOT_KILLFAM = 1; | |||||||||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||||||||||
| 31 | 47 | $GOT_PTY = 0; | |||||||||||||||||||||||||||
| 32 | 47 | eval { | |||||||||||||||||||||||||||
| 33 | 47 | require IO::Pty; | |||||||||||||||||||||||||||
| 34 | 47 | $GOT_PTY = 1; | |||||||||||||||||||||||||||
| 35 | }; | ||||||||||||||||||||||||||||
| 36 | 47 | ▶ | if ( $^O eq 'MSWin32' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | require POE::Wheel::Run::Win32; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # MSWin32: Disable critical error popups | ||||||||||||||||||||||||||||
| 40 | # Thanks to https://rt.cpan.org/Public/Bug/Display.html?id=56547 | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # Call kernel32.SetErrorMode(SEM_FAILCRITICALERRORS): | ||||||||||||||||||||||||||||
| 43 | # "The system does not display the critical-error-handler message box. | ||||||||||||||||||||||||||||
| 44 | # Instead, the system sends the error to the calling process." and | ||||||||||||||||||||||||||||
| 45 | # "A child process inherits the error mode of its parent process." | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ( eval { require Win32API::File } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | Win32API::File->import( qw( SetErrorMode SEM_FAILCRITICALERRORS SEM_NOGPFAULTERRORBOX ) ); | |||||||||||||||||||||||||||
| 48 | 0 | SetErrorMode( SEM_FAILCRITICALERRORS() | SEM_NOGPFAULTERRORBOX() ); | |||||||||||||||||||||||||||
| 49 | } else { | ||||||||||||||||||||||||||||
| 50 | 0 | warn "Unable to use Win32API::File -> $@"; | |||||||||||||||||||||||||||
| 51 | 0 | warn 'This means sometimes perl.exe will popup a dialog box... Annoying!'; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 47 | my @cmds = qw(check index smoke); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | sub check { | ||||||||||||||||||||||||||||
| 59 | 7 | ▶ | my $package = shift; | ||||||||||||||||||||||||||
|
Subroutine
check: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 7 | return $package->spawn( @_, command => 'check' ); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | sub index { | ||||||||||||||||||||||||||||
| 64 | 5 | ▶ | my $package = shift; | ||||||||||||||||||||||||||
|
Subroutine
index: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 65 | 5 | return $package->spawn( @_, command => 'index' ); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | sub smoke { | ||||||||||||||||||||||||||||
| 69 | 12 | ▶ | my $package = shift; | ||||||||||||||||||||||||||
|
Subroutine
smoke: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 12 | return $package->spawn( @_, command => 'smoke' ); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | sub spawn { | ||||||||||||||||||||||||||||
| 74 | 108 | ▶ | my $package = shift; | ||||||||||||||||||||||||||
|
Subroutine
spawn: called CC=25 SCAR=35.8
Pod
documented
| |||||||||||||||||||||||||||||
| 75 | 108 | my %opts = @_; | |||||||||||||||||||||||||||
| 76 | 108 | my $extra = { map { ( $_ => delete $opts{$_} ) } grep { /^\_/ } keys %opts }; | |||||||||||||||||||||||||||
| 77 | 108 | $opts{extra} = $extra; | |||||||||||||||||||||||||||
| 78 | 108 | $opts{lc $_} = delete $opts{$_} for keys %opts; | |||||||||||||||||||||||||||
| 79 | 108 | my $options = delete $opts{options}; | |||||||||||||||||||||||||||
| 80 | 108 | ▶ | unless ( $opts{event} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | carp "The 'event' parameter is a mandatory requirement\n"; | |||||||||||||||||||||||||||
| 82 | 0 | return; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 108 | ▶ | $opts{idle} = 600 unless $opts{idle}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 108 | ▶ | $opts{timeout} = 3600 unless $opts{timeout}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 108 | ▶ | $opts{timer} = 60 unless $opts{timer}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 108 | ▶ | $opts{reaper} = 30 unless $opts{reaper}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 108 | ▶ | $opts{type} = 'CPANPLUS::YACSmoke' unless $opts{type}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 108 | ▶ | $opts{command} = lc $opts{command} || 'check'; | ||||||||||||||||||||||||||
|
Condition50%1/2
lc $opts{'command'} || 'check'
MC/DC0%0/1
lc $opts{'command'} || 'check'
lc $opts{'command'}
Truth table50%1/2
A
A= lc $opts{'command'}
| |||||||||||||||||||||||||||||
| 90 | 108 | ▶ | $opts{command} = 'check' unless grep { $_ eq $opts{command} } @cmds; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 108 | ▶ | $opts{perl} = $^X unless $opts{perl}; # and -e $opts{perl}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 108 | ▶ | $opts{no_log} = 0 unless $opts{no_log}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 108 | ▶ | $opts{check_warnings} = 1 unless exists $opts{check_warnings}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 108 | ▶ | if ( $opts{check_warnings} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 108 | require String::Perl::Warnings; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 108 | ▶ | if ( $opts{command} eq 'smoke' and !$opts{module} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opts{"command"} eq "smoke" and not $opts{"module"}
MC/DC0%0/2
$opts{"command"} eq "smoke" and not $opts{"module"}
$opts{"command"} eq "smoke"
not $opts{"module"}
Truth table66%2/3
A and not(B)
A= $opts{"command"} eq "smoke"B= not $opts{"module"}
| |||||||||||||||||||||||||||||
| 100 | 0 | carp "You must specify a 'module' with 'smoke'\n"; | |||||||||||||||||||||||||||
| 101 | 0 | return; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | 108 | my $self = bless \%opts, $package; | |||||||||||||||||||||||||||
| 104 | 108 | my @backends = $self->backends(); | |||||||||||||||||||||||||||
| 105 | 108 | my ($type) = grep { /\Q$opts{type}\E$/ } @backends; | |||||||||||||||||||||||||||
| 106 | 108 | ▶ | unless ( $type ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 1 | carp "No such backend '$opts{type}'\n"; | |||||||||||||||||||||||||||
| 108 | 1 | return; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | 107 | eval "require $type;"; | |||||||||||||||||||||||||||
| 111 | 107 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 0 | carp "Could not load '$type' '$@'\n"; | |||||||||||||||||||||||||||
| 113 | 0 | return; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | 107 | $self->{backend} = $type->new(); | |||||||||||||||||||||||||||
| 116 | 107 | ▶ | unless ( $self->{backend} or $self->{backend}->can($self->{command}) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"backend"} or $self->{"backend"}->can($self->{"command"})
MC/DC0%0/2
$self->{"backend"} or $self->{"backend"}->can($self->{"command"})
$self->{"backend"}
$self->{"backend"}->can($self->{"command"})
Truth table33%1/3
A or B
A= $self->{"backend"}B= $self->{"backend"}->can($self->{"command"})
| |||||||||||||||||||||||||||||
| 117 | 0 | croak "Problem loading backend '$type'\n"; | |||||||||||||||||||||||||||
| 118 | 0 | return; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 107 | ▶ | if ( $self->{backend}->can('digest') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 107 | $self->{_reset_digest} = $self->{backend}->digest(); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | 107 | my $cmd = $self->{command}; | |||||||||||||||||||||||||||
| 124 | 107 | $self->{program} = $self->{backend}->$cmd; | |||||||||||||||||||||||||||
| 125 | 107 | ▶ | unless ( $self->{program} or ref $self->{program} eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"program"} or ref $self->{"program"} eq "ARRAY"
MC/DC0%0/2
$self->{"program"} or ref $self->{"program"} eq "ARRAY"
$self->{"program"}
ref $self->{"program"} eq "ARRAY"
Truth table33%1/3
A or B
A= $self->{"program"}B= ref $self->{"program"} eq "ARRAY"
| |||||||||||||||||||||||||||||
| 126 | 0 | carp "The backend method '$cmd' did not return an arrayref\n"; | |||||||||||||||||||||||||||
| 127 | 0 | return; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | 107 | unshift @{ $self->{program} }, $self->{perl}; | |||||||||||||||||||||||||||
| 130 | 107 | ▶ | push @{ $self->{program} }, $self->{module} if $cmd eq 'smoke'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 107 | ▶ | $self->{session_id} = POE::Session->create( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | package_states => [ | ||||||||||||||||||||||||||||
| 133 | $self => { shutdown => '_shutdown', }, | ||||||||||||||||||||||||||||
| 134 | $self => [qw(_start _spawn_wheel _wheel_error _wheel_closed _wheel_stdout _wheel_stderr _wheel_idle _wheel_reap _wheel_kill _sig_child)], | ||||||||||||||||||||||||||||
| 135 | ], | ||||||||||||||||||||||||||||
| 136 | heap => $self, | ||||||||||||||||||||||||||||
| 137 | ( ref($options) eq 'HASH' ? ( options => $options ) : () ), | ||||||||||||||||||||||||||||
| 138 | )->ID(); | ||||||||||||||||||||||||||||
| 139 | 107 | return $self; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | sub session_id { | ||||||||||||||||||||||||||||
| 143 | 1 | ▶ | return $_[0]->{session_id}; | ||||||||||||||||||||||||||
|
Subroutine
session_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | sub current_log { | ||||||||||||||||||||||||||||
| 147 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
current_log: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | return unless $self->{_wheel_log}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 0 | my $item = Storable::dclone( $self->{_wheel_log} ); | |||||||||||||||||||||||||||
| 150 | 0 | return $item; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | sub shutdown { | ||||||||||||||||||||||||||||
| 154 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
shutdown: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 155 | 1 | $poe_kernel->post( $self->session_id() => 'shutdown' => @_ ); | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | sub _start { | ||||||||||||||||||||||||||||
| 159 | 107 | ▶ | my ($kernel,$sender,$self) = @_[KERNEL,SENDER,OBJECT]; | ||||||||||||||||||||||||||
|
Subroutine
_start: called CC=7 SCAR=21.6
| |||||||||||||||||||||||||||||
| 160 | 107 | $self->{session_id} = $_[SESSION]->ID(); | |||||||||||||||||||||||||||
| 161 | 107 | ▶ | if ( $kernel == $sender and !$self->{session} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$kernel == $sender and not $self->{"session"}
MC/DC0%0/2
$kernel == $sender and not $self->{"session"}
$kernel == $sender
not $self->{"session"}
Truth table33%1/3
A and not(B)
A= $kernel == $senderB= not $self->{"session"}
| |||||||||||||||||||||||||||||
| 162 | 0 | croak "Not called from another POE session and 'session' wasn't set\n"; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | 107 | my $sender_id; | |||||||||||||||||||||||||||
| 165 | 107 | ▶ | if ( $self->{session} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if ( my $ref = $kernel->alias_resolve( $self->{session} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 0 | $sender_id = $ref->ID(); | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | else { | ||||||||||||||||||||||||||||
| 170 | 0 | croak "Could not resolve 'session' to a valid POE session\n"; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | else { | ||||||||||||||||||||||||||||
| 174 | 107 | $sender_id = $sender->ID(); | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | 107 | $kernel->refcount_increment( $sender_id, __PACKAGE__ ); | |||||||||||||||||||||||||||
| 177 | 107 | $self->{session} = $sender_id; | |||||||||||||||||||||||||||
| 178 | 107 | ▶ | $kernel->detach_myself() if $kernel != $sender; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 107 | $self->{_wheel_log} = [ ]; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 107 | ▶ | if ( !$self->{_reset_digest} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 74 | $self->_tie_digests(); | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | else { | ||||||||||||||||||||||||||||
| 186 | 33 | $self->{_digests} = { }; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 107 | $self->{_loop_detect} = 0; | |||||||||||||||||||||||||||
| 190 | 107 | $self->{start_time} = time(); | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 107 | $kernel->yield( '_spawn_wheel' ); | |||||||||||||||||||||||||||
| 193 | 107 | return; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | sub _shutdown { | ||||||||||||||||||||||||||||
| 197 | 1 | ▶ | my ($kernel,$self) = @_[KERNEL,OBJECT]; | ||||||||||||||||||||||||||
|
Subroutine
_shutdown: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 198 | 1 | ▶ | if ( !$self->{_reset_digest} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 1 | $self->_untie_digests(); | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||
| 202 | 0 | delete $self->{_digests}; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | 1 | $self->{term_kill} = 1; | |||||||||||||||||||||||||||
| 205 | 1 | $kernel->yield( '_wheel_kill', 'Killing current due to component shutdown event' ); | |||||||||||||||||||||||||||
| 206 | 1 | return; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | # Digests tie and untie | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | sub _tie_digests { | ||||||||||||||||||||||||||||
| 212 | 74 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_tie_digests: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 213 | 74 | $self->{_tempdir} = File::Temp->newdir(); | |||||||||||||||||||||||||||
| 214 | 74 | $self->{_tmpdirname} = $self->{_tempdir}->dirname; | |||||||||||||||||||||||||||
| 215 | 74 | my $file = File::Spec->catfile( $self->{_tmpdirname}, 'digests.dat' ); | |||||||||||||||||||||||||||
| 216 | 74 | $self->{_digests} = { }; | |||||||||||||||||||||||||||
| 217 | 74 | ▶ | tie %{ $self->{_digests} }, 'SDBM_File', $file, O_CREAT|O_RDWR, 0644 or die "Could not tie: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 74 | return 1; | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | sub _untie_digests { | ||||||||||||||||||||||||||||
| 222 | 75 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_untie_digests: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 223 | 75 | ▶ | if ( $self->{_digests} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | 74 | untie %{ $self->{_digests} }; | |||||||||||||||||||||||||||
| 225 | 74 | delete $self->{_digests}; | |||||||||||||||||||||||||||
| 226 | 74 | delete $self->{_tempdir}; | |||||||||||||||||||||||||||
| 227 | 74 | ▶ | rmtree( $self->{_tmpdirname} ) if -d $self->{_tmpdirname}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | 75 | return 1; | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | sub _spawn_wheel { | ||||||||||||||||||||||||||||
| 233 | 107 | ▶ | my ($kernel,$self) = @_[KERNEL,OBJECT]; | ||||||||||||||||||||||||||
|
Subroutine
_spawn_wheel: called CC=8 SCAR=21.1
| |||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | # do we need to process callbacks? | ||||||||||||||||||||||||||||
| 236 | 107 | ▶ | if ( $self->{do_callback} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | # Ask it if we should process this job or not? | ||||||||||||||||||||||||||||
| 238 | 6 | ▶ | unless ( $self->{do_callback}->( 'BEFORE', $self ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | 1 | ▶ | warn "Callback denied job, aborting!\n" if $self->{debug} or $ENV{PERL5_SMOKEBOX_DEBUG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
MC/DC0%0/2
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
$self->{"debug"}
$ENV{"PERL5_SMOKEBOX_DEBUG"}
Truth table33%1/3
A or B
A= $self->{"debug"}B= $ENV{"PERL5_SMOKEBOX_DEBUG"}
| |||||||||||||||||||||||||||||
| 240 | 1 | my $job = $self->_finalize_job( -1 ); | |||||||||||||||||||||||||||
| 241 | 1 | $job->{cb_kill} = 1; | |||||||||||||||||||||||||||
| 242 | 1 | $kernel->post( $self->{session}, $self->{event}, $job ); | |||||||||||||||||||||||||||
| 243 | 1 | return; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | # Set appropriate %ENV values before we fork() | ||||||||||||||||||||||||||||
| 248 | my $sanctify = Env::Sanctify->sanctify( | ||||||||||||||||||||||||||||
| 249 | env => $self->{env}, | ||||||||||||||||||||||||||||
| 250 | 106 | sanctify => [ | |||||||||||||||||||||||||||
| 251 | '^POE_', | ||||||||||||||||||||||||||||
| 252 | '^PERL5_SMOKEBOX', | ||||||||||||||||||||||||||||
| 253 | '^HARNESS_', | ||||||||||||||||||||||||||||
| 254 | '^(PERL5LIB|TAP_VERSION|TEST_VERBOSE)$', | ||||||||||||||||||||||||||||
| 255 | '^AUTHOR_TESTING$', | ||||||||||||||||||||||||||||
| 256 | '^PERL_TEST', | ||||||||||||||||||||||||||||
| 257 | ] ); | ||||||||||||||||||||||||||||
| 258 | 106 | my $type = 'POE::Wheel::Run'; | |||||||||||||||||||||||||||
| 259 | 106 | ▶ | $type .= '::Win32' if $^O eq 'MSWin32'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 260 | $self->{wheel} = $type->new( | ||||||||||||||||||||||||||||
| 261 | Program => $self->{program}, | ||||||||||||||||||||||||||||
| 262 | 106 | ▶ | StdoutEvent => '_wheel_stdout', | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | StderrEvent => '_wheel_stderr', | ||||||||||||||||||||||||||||
| 264 | StdoutFilter => POE::Filter::Line->new( InputLiteral => "\n" ), | ||||||||||||||||||||||||||||
| 265 | StderrFilter => POE::Filter::Line->new( InputLiteral => "\n" ), | ||||||||||||||||||||||||||||
| 266 | ErrorEvent => '_wheel_error', | ||||||||||||||||||||||||||||
| 267 | CloseEvent => '_wheel_closed', | ||||||||||||||||||||||||||||
| 268 | ( $GOT_PTY ? ( Conduit => 'pty-pipe' ) : () ), | ||||||||||||||||||||||||||||
| 269 | ); | ||||||||||||||||||||||||||||
| 270 | # Restore the %ENV values | ||||||||||||||||||||||||||||
| 271 | 106 | $sanctify->restore(); | |||||||||||||||||||||||||||
| 272 | 106 | $self->{_wheel_time} = time(); | |||||||||||||||||||||||||||
| 273 | 106 | $self->{PID} = $self->{wheel}->PID(); | |||||||||||||||||||||||||||
| 274 | 106 | $kernel->sig_child( $self->{PID}, '_sig_child' ); | |||||||||||||||||||||||||||
| 275 | 106 | ▶ | $kernel->delay( '_wheel_idle', $self->{timer} ) unless $self->{command} eq 'index'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | 106 | return; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | sub _sig_child { | ||||||||||||||||||||||||||||
| 280 | 106 | ▶ | my ($kernel,$self,$thing,$pid,$status) = @_[KERNEL,OBJECT,ARG0..ARG2]; | ||||||||||||||||||||||||||
|
Subroutine
_sig_child: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||
| 281 | 106 | ▶ | push @{ $self->{_wheel_log} }, "$thing $pid $status" if ! $self->{no_log}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 282 | 106 | ▶ | warn "$thing $pid $status\n" if $self->{debug} or $ENV{PERL5_SMOKEBOX_DEBUG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
MC/DC0%0/2
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
$self->{"debug"}
$ENV{"PERL5_SMOKEBOX_DEBUG"}
Truth table33%1/3
A or B
A= $self->{"debug"}B= $ENV{"PERL5_SMOKEBOX_DEBUG"}
| |||||||||||||||||||||||||||||
| 283 | 106 | $kernel->sig_handled(); | |||||||||||||||||||||||||||
| 284 | 106 | $kernel->delay( '_wheel_idle' ); | |||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 106 | my $job = $self->_finalize_job( $status ); | |||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | # do we need to process callbacks? | ||||||||||||||||||||||||||||
| 289 | 106 | ▶ | if ( $self->{do_callback} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | # Inform the callback that the job is done | ||||||||||||||||||||||||||||
| 291 | 5 | $self->{do_callback}->( 'AFTER', $self, $job ); | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 106 | $kernel->post( $self->{session}, $self->{event}, $job ); | |||||||||||||||||||||||||||
| 295 | 106 | ▶ | $kernel->delay( '_wheel_reap' => $self->{reaper} ) if $self->{wheel}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | 106 | return; | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | sub _finalize_job { | ||||||||||||||||||||||||||||
| 300 | 107 | ▶ | my( $self, $status ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_finalize_job: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 107 | $self->{end_time} = time(); | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 107 | ▶ | if ( !$self->{_reset_digest} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 74 | $self->_untie_digests(); | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | else { | ||||||||||||||||||||||||||||
| 308 | 33 | delete $self->{_digests}; | |||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 107 | delete $self->{_loop_detect}; | |||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 107 | my $job = { }; | |||||||||||||||||||||||||||
| 314 | 107 | $job->{status} = $status; | |||||||||||||||||||||||||||
| 315 | 107 | $job->{log} = $self->{_wheel_log}; | |||||||||||||||||||||||||||
| 316 | 107 | $job->{$_} = $self->{extra}->{$_} for keys %{ $self->{extra} }; | |||||||||||||||||||||||||||
| 317 | 107 | $job->{$_} = $self->{$_} for grep { $self->{$_} } qw(command env PID start_time end_time idle_kill excess_kill term_kill perl type); | |||||||||||||||||||||||||||
| 318 | 107 | ▶ | $job->{program} = $self->{program} if $self->{debug} or $ENV{PERL5_SMOKEBOX_DEBUG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
MC/DC0%0/2
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
$self->{"debug"}
$ENV{"PERL5_SMOKEBOX_DEBUG"}
Truth table33%1/3
A or B
A= $self->{"debug"}B= $ENV{"PERL5_SMOKEBOX_DEBUG"}
| |||||||||||||||||||||||||||||
| 319 | 107 | ▶ | $job->{module} = $self->{module} if $self->{command} eq 'smoke'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 320 | 107 | $poe_kernel->refcount_decrement( $self->{session}, __PACKAGE__ ); | |||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 107 | return $job; | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | sub _wheel_reap { | ||||||||||||||||||||||||||||
| 326 | 0 | ▶ | my ($kernel,$self) = @_[KERNEL,OBJECT]; | ||||||||||||||||||||||||||
|
Subroutine
_wheel_reap: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 327 | 0 | ▶ | warn "wheel reaped\n" if $self->{debug} or $ENV{PERL5_SMOKEBOX_DEBUG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
MC/DC0%0/2
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
$self->{"debug"}
$ENV{"PERL5_SMOKEBOX_DEBUG"}
Truth table0%0/3
A or B
A= $self->{"debug"}B= $ENV{"PERL5_SMOKEBOX_DEBUG"}
| |||||||||||||||||||||||||||||
| 328 | 0 | delete $self->{wheel}; | |||||||||||||||||||||||||||
| 329 | 0 | return; | |||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | sub _wheel_error { | ||||||||||||||||||||||||||||
| 333 | 212 | ▶ | my ($self,$operation,$errnum,$errstr,$wheel_id) = @_[OBJECT,ARG0..ARG3]; | ||||||||||||||||||||||||||
|
Subroutine
_wheel_error: called CC=5 SCAR=17.2
| |||||||||||||||||||||||||||||
| 334 | 212 | ▶ | $errstr = "remote end closed" if $operation eq "read" and !$errnum; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$operation eq "read" and not $errnum
MC/DC50%1/2
$operation eq "read" and not $errnum
$operation eq "read"
not $errnum
Truth table66%2/3
A and not(B)
A= $operation eq "read"B= not $errnum
| |||||||||||||||||||||||||||||
| 335 | 212 | ▶ | warn "wheel $wheel_id generated $operation error $errnum: $errstr\n" if $self->{debug} or $ENV{PERL5_SMOKEBOX_DEBUG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
MC/DC0%0/2
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
$self->{"debug"}
$ENV{"PERL5_SMOKEBOX_DEBUG"}
Truth table33%1/3
A or B
A= $self->{"debug"}B= $ENV{"PERL5_SMOKEBOX_DEBUG"}
| |||||||||||||||||||||||||||||
| 336 | 212 | return; | |||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | sub _wheel_closed { | ||||||||||||||||||||||||||||
| 340 | 106 | ▶ | my ($kernel,$self) = @_[KERNEL,OBJECT]; | ||||||||||||||||||||||||||
|
Subroutine
_wheel_closed: called CC=3 SCAR=11.6
| |||||||||||||||||||||||||||||
| 341 | 106 | $kernel->delay( '_wheel_idle' ); | |||||||||||||||||||||||||||
| 342 | 106 | $kernel->delay( '_wheel_reap' ); | |||||||||||||||||||||||||||
| 343 | 106 | ▶ | warn "wheel closed\n" if $self->{debug} or $ENV{PERL5_SMOKEBOX_DEBUG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
MC/DC0%0/2
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
$self->{"debug"}
$ENV{"PERL5_SMOKEBOX_DEBUG"}
Truth table33%1/3
A or B
A= $self->{"debug"}B= $ENV{"PERL5_SMOKEBOX_DEBUG"}
| |||||||||||||||||||||||||||||
| 344 | 106 | delete $self->{wheel}; | |||||||||||||||||||||||||||
| 345 | 106 | return; | |||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | sub _wheel_stdout { | ||||||||||||||||||||||||||||
| 349 | 1411 | ▶ | my ($self, $input, $wheel_id) = @_[OBJECT, ARG0, ARG1]; | ||||||||||||||||||||||||||
|
Subroutine
_wheel_stdout: called CC=6 SCAR=18.1
| |||||||||||||||||||||||||||||
| 350 | 1411 | ▶ | return if $self->{_killed}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 721 | $self->{_wheel_time} = time(); | |||||||||||||||||||||||||||
| 352 | 721 | ▶ | push @{ $self->{_wheel_log} }, $input if ! $self->{no_log}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 353 | 721 | ▶ | warn $input, "\n" if $self->{debug} or $ENV{PERL5_SMOKEBOX_DEBUG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
MC/DC0%0/2
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
$self->{"debug"}
$ENV{"PERL5_SMOKEBOX_DEBUG"}
Truth table33%1/3
A or B
A= $self->{"debug"}B= $ENV{"PERL5_SMOKEBOX_DEBUG"}
| |||||||||||||||||||||||||||||
| 354 | 721 | ▶ | if ( $self->_detect_loop( $input, 'stdout' ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 355 | 1 | $self->{excess_kill} = 1; | |||||||||||||||||||||||||||
| 356 | 1 | $poe_kernel->yield( '_wheel_kill', 'Killing current run due to detection of looping output' ); | |||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||
| 358 | 721 | return; | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | sub _wheel_stderr { | ||||||||||||||||||||||||||||
| 362 | 42 | ▶ | my ($self, $input, $wheel_id) = @_[OBJECT, ARG0, ARG1]; | ||||||||||||||||||||||||||
|
Subroutine
_wheel_stderr: called CC=7 SCAR=25.7
| |||||||||||||||||||||||||||||
| 363 | 42 | ▶ | return if $self->{_killed}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 364 | 42 | $self->{_wheel_time} = time(); | |||||||||||||||||||||||||||
| 365 | 42 | ▶ | push @{ $self->{_wheel_log} }, $input if ! $self->{no_log}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 366 | 42 | ▶ | if ( $self->{debug} or $ENV{PERL5_SMOKEBOX_DEBUG} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
MC/DC0%0/2
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
$self->{"debug"}
$ENV{"PERL5_SMOKEBOX_DEBUG"}
Truth table33%1/3
A or B
A= $self->{"debug"}B= $ENV{"PERL5_SMOKEBOX_DEBUG"}
| |||||||||||||||||||||||||||||
| 367 | 0 | ▶ | if ( length( $input ) > 5000 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 368 | 0 | warn "[SUPPRESSED OUTPUT > 5000]\n"; | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | else { | ||||||||||||||||||||||||||||
| 371 | 0 | warn $input, "\n"; | |||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | 42 | ▶ | if ( $self->_detect_loop( $input, 'stderr' ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | 0 | $self->{excess_kill} = 1; | |||||||||||||||||||||||||||
| 376 | 0 | $poe_kernel->yield( '_wheel_kill', 'Killing current run due to detection of looping output' ); | |||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||
| 378 | 42 | return; | |||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | sub _detect_loop { | ||||||||||||||||||||||||||||
| 382 | 763 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_detect_loop: called CC=16 SCAR=33.2
| |||||||||||||||||||||||||||||
| 383 | 763 | ▶ | my $input = shift || return; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 384 | 763 | ▶ | my $handle = shift || 'stdout'; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 'stdout'
MC/DC0%0/1
shift() || 'stdout'
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 385 | 763 | ▶ | return if $self->{_loop_detect}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 386 | 349 | ▶ | if ( my $reset = $self->{_reset_digest} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 387 | 33 | ▶ | if ( eval { $input =~ $reset } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 388 | 0 | ▶ | warn "Resetting digests\n" if $self->{debug} or $ENV{PERL5_SMOKEBOX_DEBUG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
MC/DC0%0/2
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
$self->{"debug"}
$ENV{"PERL5_SMOKEBOX_DEBUG"}
Truth table0%0/3
A or B
A= $self->{"debug"}B= $ENV{"PERL5_SMOKEBOX_DEBUG"}
| |||||||||||||||||||||||||||||
| 389 | 0 | $self->{_digests} = { }; | |||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||
| 392 | 349 | ▶ | return if $input =~ /^\[(MSG|ERROR)\]/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 393 | 349 | my $digest = sha256_hex( $input ); | |||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 349 | my $weighting; | |||||||||||||||||||||||||||
| 396 | 349 | ▶ | if ( ON_FREEBSD and $handle eq 'stderr' and _fbsd_compiler_warnings($input) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | $weighting = 0.01; | ||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | ▶ | elsif ( $self->{check_warnings} and length( $input ) <= 5000 ) { | |||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"check_warnings"} and length $input <= 5000
MC/DC0%0/2
$self->{"check_warnings"} and length $input <= 5000
$self->{"check_warnings"}
length $input <= 5000
Truth table33%1/3
A and B
A= $self->{"check_warnings"}B= length $input <= 5000
| |||||||||||||||||||||||||||||
| 400 | 349 | ▶ | $weighting = ( $handle eq 'stderr' and String::Perl::Warnings::is_warning($input) ) ? 1 : 10; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$handle eq "stderr" and String::Perl::Warnings::is_warning($input)
MC/DC0%0/2
$handle eq "stderr" and String::Perl::Warnings::is_warning($input)
$handle eq "stderr"
String::Perl::Warnings::is_warning($input)
Truth table66%2/3
A and B
A= $handle eq "stderr"B= String::Perl::Warnings::is_warning($input)
| |||||||||||||||||||||||||||||
| 401 | } else { | ||||||||||||||||||||||||||||
| 402 | 0 | ▶ | $weighting = $handle eq 'stderr' ? 1 : 10; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | 349 | ▶ | if ( exists $self->{_digests}->{ $digest } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 406 | 276 | $self->{_digests}->{ $digest } += $weighting; | |||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | else { | ||||||||||||||||||||||||||||
| 409 | 73 | $self->{_digests}->{ $digest } = $weighting; | |||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||
| 411 | 349 | ▶ | return unless ++$self->{_digests}->{ $digest } > 3000; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 412 | 1 | return $self->{_loop_detect} = 1; | |||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | { | ||||||||||||||||||||||||||||
| 416 | 47 | my $re = Regexp::Assemble->new() | |||||||||||||||||||||||||||
| 417 | ->add('note: expanded from macro') | ||||||||||||||||||||||||||||
| 418 | ->add('note: .+? token is here') | ||||||||||||||||||||||||||||
| 419 | ->add('tokens terminating statement expression appear in different macro expansion contexts') | ||||||||||||||||||||||||||||
| 420 | ->add('tokens introducing statement expression appear in different macro expansion contexts') | ||||||||||||||||||||||||||||
| 421 | ->add('STMT_START') | ||||||||||||||||||||||||||||
| 422 | ->add('STMT_END') | ||||||||||||||||||||||||||||
| 423 | ->add('PUSHMARK') | ||||||||||||||||||||||||||||
| 424 | ->add('XSRETURN') | ||||||||||||||||||||||||||||
| 425 | ->add('EXTEND') | ||||||||||||||||||||||||||||
| 426 | ->add('SvTAINT') | ||||||||||||||||||||||||||||
| 427 | ->add('SvCUR_set') | ||||||||||||||||||||||||||||
| 428 | ->add('PUSHTARG') | ||||||||||||||||||||||||||||
| 429 | ->add('^') | ||||||||||||||||||||||||||||
| 430 | ->add('~') | ||||||||||||||||||||||||||||
| 431 | ->re; | ||||||||||||||||||||||||||||
| 432 | sub _fbsd_compiler_warnings { | ||||||||||||||||||||||||||||
| 433 | 0 | ▶ | my $line = shift; | ||||||||||||||||||||||||||
|
Subroutine
_fbsd_compiler_warnings: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 434 | 0 | ▶ | return 1 if $line =~ m!$re!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 435 | 0 | return; | |||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | 47 | sub _wheel_idle { | |||||||||||||||||||||||||||
| 440 | 2 | ▶ | my ($kernel,$self) = @_[KERNEL,OBJECT]; | ||||||||||||||||||||||||||
|
Subroutine
_wheel_idle: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||
| 441 | 2 | my $now = time(); | |||||||||||||||||||||||||||
| 442 | 2 | ▶ | if ( $now - $self->{_wheel_time} >= $self->{idle} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 443 | 1 | $self->{idle_kill} = 1; | |||||||||||||||||||||||||||
| 444 | 1 | $kernel->yield( '_wheel_kill', 'Killing current run due to excessive idle' ); | |||||||||||||||||||||||||||
| 445 | 1 | return; | |||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | 1 | ▶ | if ( $now - $self->{start_time} >= $self->{timeout} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 448 | 1 | $self->{excess_kill} = 1; | |||||||||||||||||||||||||||
| 449 | 1 | $kernel->yield( '_wheel_kill', 'Killing current run due to excessive run-time' ); | |||||||||||||||||||||||||||
| 450 | 1 | return; | |||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||
| 452 | 0 | $kernel->delay( '_wheel_idle', 60 ); | |||||||||||||||||||||||||||
| 453 | 0 | return; | |||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | sub _wheel_kill { | ||||||||||||||||||||||||||||
| 457 | 4 | ▶ | my ($kernel,$self,$reason) = @_[KERNEL,OBJECT,ARG0]; | ||||||||||||||||||||||||||
|
Subroutine
_wheel_kill: called CC=12 SCAR=30.4
| |||||||||||||||||||||||||||||
| 458 | 4 | ▶ | return if $self->{_killed}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 459 | 4 | $self->{_killed} = 1; | |||||||||||||||||||||||||||
| 460 | 4 | ▶ | push @{ $self->{_wheel_log} }, $reason if ! $self->{no_log}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 461 | 4 | ▶ | warn $reason, "\n" if $self->{debug} or $ENV{PERL5_SMOKEBOX_DEBUG}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
MC/DC0%0/2
$self->{"debug"} or $ENV{"PERL5_SMOKEBOX_DEBUG"}
$self->{"debug"}
$ENV{"PERL5_SMOKEBOX_DEBUG"}
Truth table33%1/3
A or B
A= $self->{"debug"}B= $ENV{"PERL5_SMOKEBOX_DEBUG"}
| |||||||||||||||||||||||||||||
| 462 | 4 | ▶ | if ( $^O eq 'MSWin32' and $self->{wheel} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$^O eq "MSWin32" and $self->{"wheel"}
MC/DC0%0/2
$^O eq "MSWin32" and $self->{"wheel"}
$^O eq "MSWin32"
$self->{"wheel"}
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= $self->{"wheel"}
| |||||||||||||||||||||||||||||
| 463 | 0 | $self->{wheel}->kill(); | |||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||
| 465 | else { | ||||||||||||||||||||||||||||
| 466 | 4 | ▶ | if ( !$self->{no_grp_kill} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 467 | 1 | ▶ | if ( $^O eq 'solaris' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 468 | 0 | ▶ | kill( 9, '-' . $self->{wheel}->PID() ) if $self->{wheel}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||
| 470 | else { | ||||||||||||||||||||||||||||
| 471 | 1 | ▶ | $self->{wheel}->kill(-9) if $self->{wheel}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | # elsif ( $GOT_KILLFAM ) { | ||||||||||||||||||||||||||||
| 475 | # _kill_family( 9, $self->{wheel}->PID() ) if $self->{wheel}; | ||||||||||||||||||||||||||||
| 476 | # } | ||||||||||||||||||||||||||||
| 477 | else { | ||||||||||||||||||||||||||||
| 478 | 3 | ▶ | $self->{wheel}->kill(9) if $self->{wheel}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||
| 481 | 4 | return; | |||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 47 | 1; | |||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | __END__ | ||||||||||||||||||||||||||||