| 1 | package Class::Action; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | $Class::Action::VERSION = '0.4'; | |||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | my ( $class, $args_hr ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 'auto_rollback' => exists $args_hr->{'auto_rollback'} && defined $args_hr->{'auto_rollback'} ? $args_hr->{'auto_rollback'} : 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 'last_errstr' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 'current_step' => undef, # N == index, undef == not started, '' == finished | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 'step_stack' => ref $args_hr->{'step_stack'} eq 'ARRAY' ? $args_hr->{'step_stack'} : [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 'exec_stack' => [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | '_needs_reset' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 'global_data' => ref $args_hr->{'global_data'} eq 'HASH' ? $args_hr->{'global_data'} : {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | ▶ | 'enable_cwd' => $args_hr->{'enable_cwd'} || 0, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition80%4/5
exists $args_hr->{"auto_rollback"} and defined $args_hr->{"auto_rollback"}
$args_hr->{'enable_cwd'} || 0
MC/DC50%1/2
exists $args_hr->{"auto_rollback"} and defined $args_hr->{"auto_rollback"}
exists $args_hr->{"auto_rollback"}
defined $args_hr->{"auto_rollback"}
MC/DC100%1/1
$args_hr->{'enable_cwd'} || 0
$args_hr->{'enable_cwd'}
Truth table66%2/3
A and B
A= exists $args_hr->{"auto_rollback"}B= defined $args_hr->{"auto_rollback"}
Truth table100%2/2
A
A= $args_hr->{'enable_cwd'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # for my $name qw(set_steps_from_class append_steps_from_class prepend_steps_from_class) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # if ( exists $args_hr->{$name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # $self->$name( ref $args_hr->{$name} eq 'ARRAY' ? @{ $args_hr->{$name} } : $args_hr->{$name} ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # } | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # } | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 6 | ▶ | if ( exists $args_hr->{'set_steps_from_class'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | $self->set_steps_from_class( ref $args_hr->{'set_steps_from_class'} eq 'ARRAY' ? @{ $args_hr->{'set_steps_from_class'} } : $args_hr->{'set_steps_from_class'} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 11 | ▶ | sub set_steps { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_steps: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 11 | my ( $self, @steps ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | 11 | ▶ | @{ $self->{'step_stack'} } = @steps == 1 && ref $steps[0] eq 'ARRAY' ? @{ $steps[0] } : @steps; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@steps == 1 and ref $steps[0] eq "ARRAY"
MC/DC0%0/2
@steps == 1 and ref $steps[0] eq "ARRAY"
@steps == 1
ref $steps[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @steps == 1B= ref $steps[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 11 | return @{ $self->{'step_stack'} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 11 | ▶ | sub set_steps_from_class { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_steps_from_class: called CC=4 SCAR=16.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 11 | my ( $self, $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 11 | ▶ | if ( !ref($class) && $class =~ m/\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $class and $class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
MC/DC0%0/2
not ref $class and $class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
not ref $class
$class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
Truth table33%1/3
not(A) and B
A= not ref $classB= $class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 11 | eval qq{ require $class; 1 }; | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 11 | ▶ | if ( $class->can('get_class_action_steps') ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 11 | $self->set_steps( $class->get_class_action_steps(@args) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->set_steps(); | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | Carp::carp("$class does not implement get_class_action_steps()"); | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 11 | return @{ $self->{'step_stack'} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub get_steps { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_steps: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return @{ $self->{'step_stack'} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub append_steps { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append_steps: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my ( $self, @steps ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | push @{ $self->{'step_stack'} }, @steps == 1 && ref $steps[0] eq 'ARRAY' ? @{ $steps[0] } : @steps; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@steps == 1 and ref $steps[0] eq "ARRAY"
MC/DC0%0/2
@steps == 1 and ref $steps[0] eq "ARRAY"
@steps == 1
ref $steps[0] eq "ARRAY"
Truth table0%0/3
A and B
A= @steps == 1B= ref $steps[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return @{ $self->{'step_stack'} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub append_steps_from_class { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append_steps_from_class: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my ( $self, $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ( !ref($class) && $class =~ m/\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $class and $class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
MC/DC0%0/2
not ref $class and $class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
not ref $class
$class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
Truth table0%0/3
not(A) and B
A= not ref $classB= $class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | eval qq{ require $class; 1 }; | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if ( $class->can('get_class_action_steps') ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $self->append_steps( $class->get_class_action_steps(@args) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | Carp::carp("$class does not implement get_class_action_steps()"); | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return @{ $self->{'step_stack'} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub prepend_steps { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepend_steps: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my ( $self, @steps ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | unshift @{ $self->{'step_stack'} }, @steps == 1 && ref $steps[0] eq 'ARRAY' ? @{ $steps[0] } : @steps; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@steps == 1 and ref $steps[0] eq "ARRAY"
MC/DC0%0/2
@steps == 1 and ref $steps[0] eq "ARRAY"
@steps == 1
ref $steps[0] eq "ARRAY"
Truth table0%0/3
A and B
A= @steps == 1B= ref $steps[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | return @{ $self->{'step_stack'} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub prepend_steps_from_class { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepend_steps_from_class: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my ( $self, $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ( !ref($class) && $class =~ m/\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $class and $class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
MC/DC0%0/2
not ref $class and $class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
not ref $class
$class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
Truth table0%0/3
not(A) and B
A= not ref $classB= $class =~ /\A[a-zA-Z0-9_]+(?:\:\:[a-zA-Z0-9_]+)*\z/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | eval qq{ require $class; 1 }; | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ( $class->can('get_class_action_steps') ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $self->prepend_steps( $class->get_class_action_steps(@args) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | Carp::carp("$class does not implement get_class_action_steps()"); | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return @{ $self->{'step_stack'} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | my $class = ref($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | return if !$class; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | my %copy = %{$self}; # copy data | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | my @step_list; | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # get your own fresh stack | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | for my $step ( @{ $copy{'step_stack'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | push @step_list, $step->clone_obj(); | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | $copy{'step_stack'} = \@step_list; | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | $copy{'global_data'} = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | $copy{'exec_stack'} = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | my $clone = bless \%copy, $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | return $clone->reset; # reset the internal state so that it is fresh | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # sub commit { | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # my ($self, @step_args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # local $self->{'auto_rollback'} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # return $self->execute(@step_args); | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # } | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 14 | ▶ | sub reset { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 14 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 14 | for my $step ( @{ $self->{'step_stack'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | 46 | $step->reset_obj_state(); | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 14 | delete $self->{'starting_cwd'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | 14 | delete $self->{'_execute'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | 14 | delete $self->{'_rollback'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | 14 | delete $self->{'_undo'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 14 | $self->{'current_step'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 14 | $self->{'last_errstr'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | 14 | $self->{'_needs_reset'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 14 | %{ $self->{'global_data'} } = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | 14 | @{ $self->{'exec_stack'} } = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 14 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 15 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=20 SCAR=30.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 15 | my ( $self, @step_args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 15 | ▶ | $self->reset() if exists $self->{'_execute'} && !$self->{'_execute'}; # we've been successfully executed so reset and go again | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $self->{"_execute"} and not $self->{"_execute"}
MC/DC100%2/2
exists $self->{"_execute"} and not $self->{"_execute"}
exists $self->{"_execute"}
not $self->{"_execute"}
Truth table100%3/3
A and not(B)
A= exists $self->{"_execute"}B= not $self->{"_execute"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 15 | ▶ | $self->reset() if $self->{'_needs_reset'}++; # called when in "examine results" state | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 15 | ▶ | return if $self->{'_execute'} || $self->{'_rollback'}; # execute() called after failed execute() or after failed rollback() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"_execute"} or $self->{"_rollback"}
MC/DC0%0/2
$self->{"_execute"} or $self->{"_rollback"}
$self->{"_execute"}
$self->{"_rollback"}
Truth table33%1/3
A or B
A= $self->{"_execute"}B= $self->{"_rollback"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 15 | ▶ | $self->set_starting_cwd() if $self->{'enable_cwd'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 15 | $self->{'_execute'}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 15 | my $execute_failed = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 15 | my $step; # more memory efficient than while my $var | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | STEP: | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 15 | ▶ | while ( $step = $self->next_step() ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 55 | my $ref = ref($step); | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | 55 | ▶ | if (!$ref) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 9 | $step = $step->new(@step_args); | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | elsif ($ref eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | $step = $step->[0]->new( @{$step}[ 1 .. scalar(@{$step}) - 1 ], \@step_args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 55 | delete $step->{'last_errstr'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 55 | ▶ | if ( !$step->execute( $self->{'global_data'}, @step_args ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 10 | ▶ | if ( $step->retry_execute( $self->{'global_data'}, @step_args ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 5 | ▶ | $self->{'last_errstr'} = $step->{'last_errstr'} if exists $step->{'last_errstr'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | ▶ | push @{ $self->{'exec_stack'} }, { 'errstr' => $step->{'last_errstr'}, 'type' => 'execute', 'step' => ( $step->state || ref($step) ), 'ns' => ref($step), 'status' => undef }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$step->state || ref $step
MC/DC0%0/2
$step->state || ref $step
$step->state
ref $step
Truth table33%1/3
A || B
A= $step->stateB= ref $step
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 5 | $step->exec_stack_runtime_handler( $self->{'exec_stack'}->[-1] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 5 | redo STEP; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | ▶ | $self->{'last_errstr'} = $step->{'last_errstr'} if exists $step->{'last_errstr'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 5 | ▶ | push @{ $self->{'exec_stack'} }, { 'errstr' => $step->{'last_errstr'}, 'type' => 'execute', 'step' => ( $step->state || ref($step) ), 'ns' => ref($step), 'status' => 0 }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$step->state || ref $step
MC/DC0%0/2
$step->state || ref $step
$step->state
ref $step
Truth table33%1/3
A || B
A= $step->stateB= ref $step
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 5 | $step->exec_stack_runtime_handler( $self->{'exec_stack'}->[-1] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 5 | $step->clean_failed_execute( $self->{'global_data'}, @step_args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | 5 | $step->reset_obj_state(); | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | 5 | $execute_failed++; | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 5 | last STEP; | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 45 | ▶ | $self->{'last_errstr'} = $step->{'last_errstr'} if exists $step->{'last_errstr'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 45 | ▶ | push @{ $self->{'exec_stack'} }, { 'errstr' => $step->{'last_errstr'}, 'type' => 'execute', 'step' => ( $step->state || ref($step) ), 'ns' => ref($step), 'status' => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$step->state || ref $step
MC/DC0%0/2
$step->state || ref $step
$step->state
ref $step
Truth table66%2/3
A || B
A= $step->stateB= ref $step
| |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 45 | $step->exec_stack_runtime_handler( $self->{'exec_stack'}->[-1] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 15 | ▶ | if ($execute_failed) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | ▶ | $self->rollback(@step_args) if $self->{'auto_rollback'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 10 | $self->{'_needs_reset'}--; | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | 10 | $self->{'_execute'}--; | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | 10 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 11 | ▶ | sub rollback { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rollback: called CC=22 SCAR=33.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 11 | my ( $self, @step_args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | 11 | ▶ | if ( !$self->{'__rollback_is_undo'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 9 | ▶ | return if !exists $self->{'_execute'} || !$self->{'_execute'}; # rollback() called before execute() or after a successful execute() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $self->{"_execute"} and $self->{"_execute"}
MC/DC50%1/2
exists $self->{"_execute"} and $self->{"_execute"}
exists $self->{"_execute"}
$self->{"_execute"}
Truth table66%2/3
A and B
A= exists $self->{"_execute"}B= $self->{"_execute"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 7 | ▶ | return if exists $self->{'_rollback'} && !$self->{'_rollback'}; # rollback() called after successful rollback() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $self->{"_rollback"} and not $self->{"_rollback"}
MC/DC100%2/2
exists $self->{"_rollback"} and not $self->{"_rollback"}
exists $self->{"_rollback"}
not $self->{"_rollback"}
Truth table100%3/3
A and not(B)
A= exists $self->{"_rollback"}B= not $self->{"_rollback"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 6 | ▶ | return if $self->{'_rollback'}++; # rollback() called after failed rollback() | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 7 | my $rollback_failed = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 7 | my $step; # more memory efficient than while my $var | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | UNDO: | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 7 | ▶ | while ( $step = $self->prev_step() ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 23 | my $ref = ref($step); | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | 23 | ▶ | if (!$ref) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $step = $step->new(@step_args); | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | elsif ($ref eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $step = $step->[0]->new( @{$step}[ 1 .. scalar(@{$step}) - 1 ], \@step_args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 23 | delete $step->{'last_errstr'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 23 | ▶ | if ( !$step->undo( $self->{'global_data'}, @step_args ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 6 | ▶ | if ( $step->retry_undo( $self->{'global_data'}, @step_args ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 3 | ▶ | $self->{'last_errstr'} = $step->{'last_errstr'} if exists $step->{'last_errstr'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 3 | ▶ | push @{ $self->{'exec_stack'} }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$step->state || ref $step
MC/DC0%0/2
$step->state || ref $step
$step->state
ref $step
Truth table33%1/3
A || B
A= $step->stateB= ref $step
| |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 'errstr' => $step->{'last_errstr'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 3 | 'type' => ( $self->{'_rollback_is_undo'} ? 'undo' : 'rollback' ), | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | 'step' => ( $step->state || ref($step) ), | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 'ns' => ref($step), | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 'status' => undef | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 3 | $step->exec_stack_runtime_handler( $self->{'exec_stack'}->[-1] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 3 | redo UNDO; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 3 | ▶ | $self->{'last_errstr'} = $step->{'last_errstr'} if exists $step->{'last_errstr'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | ▶ | push @{ $self->{'exec_stack'} }, { 'errstr' => $step->{'last_errstr'}, 'type' => ( $self->{'_rollback_is_undo'} ? 'undo' : 'rollback' ), 'step' => ( $step->state || ref($step) ), 'ns' => ref($step), 'status' => 0 }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$step->state || ref $step
MC/DC0%0/2
$step->state || ref $step
$step->state
ref $step
Truth table33%1/3
A || B
A= $step->stateB= ref $step
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | $step->exec_stack_runtime_handler( $self->{'exec_stack'}->[-1] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 3 | $step->clean_failed_undo( $self->{'global_data'}, @step_args ); | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | 3 | $step->reset_obj_state(); | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | 3 | $rollback_failed++; | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 3 | last UNDO; | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 17 | ▶ | $self->{'last_errstr'} = $step->{'last_errstr'} if exists $step->{'last_errstr'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 17 | ▶ | push @{ $self->{'exec_stack'} }, { 'errstr' => $step->{'last_errstr'}, 'type' => ( $self->{'_rollback_is_undo'} ? 'undo' : 'rollback' ), 'step' => ( $step->state || ref($step) ), 'ns' => ref($step), 'status' => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$step->state || ref $step
MC/DC0%0/2
$step->state || ref $step
$step->state
ref $step
Truth table33%1/3
A || B
A= $step->stateB= ref $step
| |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 17 | $step->exec_stack_runtime_handler( $self->{'exec_stack'}->[-1] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 7 | ▶ | return if $rollback_failed; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 4 | $self->{'_rollback'}--; | |||||||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 4 | ▶ | sub undo { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
undo: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 4 | my ( $self, @step_args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 4 | ▶ | return if !exists $self->{'_execute'} || $self->{'_execute'} || !$self->is_at_end(); # succesful execute() has happened | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not exists $self->{"_execute"} or $self->{"_execute"} or not $self->is_at_end
not exists $self->{"_execute"} or $self->{"_execute"}
MC/DC66%2/3
not exists $self->{"_execute"} or $self->{"_execute"} or not $self->is_at_end
not exists $self->{"_execute"}
$self->{"_execute"}
not $self->is_at_end
Truth table75%3/4
not(A) or B or not(C)
A= not exists $self->{"_execute"}B= $self->{"_execute"}C= not $self->is_at_end
| |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 2 | $self->{'__rollback_is_undo'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 299 | 2 | $self->{'_undo'}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | 2 | my $rc = $self->rollback(@step_args); | |||||||||||||||||||||||||||||||||||||||||||||
| 301 | 2 | delete $self->{'__rollback_is_undo'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 302 | 2 | ▶ | $self->{'_undo'}-- if $rc; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 2 | ▶ | return 1 if $rc; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub execute_failed { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_failed: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | return 1 if $_[0]->{'_execute'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | sub execute_called { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_called: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | return 1 if exists $_[0]->{'_execute'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | sub rollback_failed { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rollback_failed: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | return 1 if $_[0]->{'_rollback'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub rollback_called { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rollback_called: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | return 1 if exists $_[0]->{'_rollback'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 3 | ▶ | sub undo_failed { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
undo_failed: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 3 | ▶ | return 1 if $_[0]->{'_undo'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 4 | ▶ | sub undo_called { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
undo_called: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 4 | ▶ | return 1 if exists $_[0]->{'_undo'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 6 | ▶ | sub get_enable_cwd { $_[0]->{'enable_cwd'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_enable_cwd: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 2 | ▶ | sub set_enable_cwd { $_[0]->{'enable_cwd'} = $_[1] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_enable_cwd: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 8 | ▶ | sub get_starting_cwd { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_starting_cwd: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 8 | ▶ | return if !exists $_[0]->{'starting_cwd'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 3 | return $_[0]->{'starting_cwd'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 3 | ▶ | sub set_starting_cwd { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_starting_cwd: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 3 | require Cwd; | |||||||||||||||||||||||||||||||||||||||||||||
| 348 | 3 | my $current = $_[0]->{'starting_cwd'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 349 | 3 | $_[0]->{'starting_cwd'} = Cwd::cwd(); | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | 3 | ▶ | return $current if $current; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 61 | ▶ | sub next_step { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_step: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 61 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 61 | my $stack_length = @{ $self->{'step_stack'} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 61 | ▶ | if ( !$stack_length ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 3 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | 3 | local $Carp::CarpLevel = $Carp::CarpLevel + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 362 | 3 | Carp::carp('This action has no steps.'); | |||||||||||||||||||||||||||||||||||||||||||||
| 363 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # why would this happen? (i.e. !used via while()) carp ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 58 | ▶ | return if $self->is_at_end(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 50 | ▶ | if ( $self->is_at_start() ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 13 | ▶ | $self->{'current_step'} ||= -1; # first time next_step() is called set current_step to 0 - 1 numeric index | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"current_step"} ||= -1
MC/DC0%0/1
$self->{"current_step"} ||= -1
$self->{"current_step"}
Truth table50%1/2
A
A= $self->{"current_step"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 50 | $self->{'current_step'}++; | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | 50 | ▶ | if ( $self->{'current_step'} == ( $stack_length - 1 ) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 8 | my $current_step = $self->{'current_step'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 376 | 8 | $self->{'current_step'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | 8 | return $self->{'step_stack'}->[$current_step]; | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 42 | return $self->{'step_stack'}->[ $self->{'current_step'} ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 25 | ▶ | sub prev_step { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prev_step: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 25 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 25 | my $stack_length = @{ $self->{'step_stack'} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # why would this happen? (i.e. none set) carp ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 25 | ▶ | if ( !$stack_length ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 1 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | local $Carp::CarpLevel = $Carp::CarpLevel + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 391 | 1 | Carp::carp('This action has no steps.'); | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # why would this happen? (i.e. !used via while()) carp ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 24 | ▶ | return if $self->is_at_start(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 20 | ▶ | if ( $self->is_at_end() ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 2 | $self->{'current_step'} = ( $stack_length - 1 ); # first time prev-step() is called set current_step to $stack_length numeric index | |||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 20 | my $current_step = $self->{'current_step'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 403 | 20 | $self->{'current_step'}--; | |||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 20 | ▶ | if ( $self->{'current_step'} < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 4 | $self->{'current_step'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 408 | 4 | return $self->{'step_stack'}->[$current_step]; | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 16 | return $self->{'step_stack'}->[$current_step]; | |||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 74 | ▶ | sub is_at_start { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_at_start: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 74 | ▶ | return 1 if !defined $_[0]->{'current_step'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 57 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 80 | ▶ | sub is_at_end { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_at_end: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 80 | ▶ | return 1 if defined $_[0]->{'current_step'} && $_[0]->{'current_step'} eq ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $_[0]{"current_step"} and $_[0]{"current_step"} eq ""
MC/DC100%2/2
defined $_[0]{"current_step"} and $_[0]{"current_step"} eq ""
defined $_[0]{"current_step"}
$_[0]{"current_step"} eq ""
Truth table100%3/3
A and B
A= defined $_[0]{"current_step"}B= $_[0]{"current_step"} eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 68 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub get_current_step { $_[0]->{'current_step'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_current_step: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | sub get_errstr { $_[0]->{'last_errstr'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_errstr: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | sub set_errstr { $_[0]->{'last_errstr'} = $_[1] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_errstr: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | sub get_auto_rollback { $_[0]->{'auto_rollback'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_auto_rollback: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 1 | ▶ | sub set_auto_rollback { $_[0]->{'auto_rollback'} = $_[1] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_auto_rollback: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 9 | ▶ | sub get_execution_state { return [ @{ $_[0]->{'exec_stack'} } ] } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_execution_state: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||