| 1 | package Test2::Harness::UI::Util::ImportModes; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Scalar::Util qw/blessed reftype/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Importer Importer => 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | my %MODES = ( | |||||||||||||||||||||||||||||||||||||||||
| 11 | summary => 5, | ||||||||||||||||||||||||||||||||||||||||||
| 12 | qvf => 10, | ||||||||||||||||||||||||||||||||||||||||||
| 13 | qvfd => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 14 | qvfds => 17, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | complete => 20, | ||||||||||||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | %MODES = ( | ||||||||||||||||||||||||||||||||||||||||||
| 19 | %MODES, | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | map {$_ => $_} values %MODES, | |||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | our @EXPORT_OK = qw/event_in_mode record_all_events mode_check record_subtest_events/; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | our %EXPORT_ANON = ( | |||||||||||||||||||||||||||||||||||||||||
| 26 | '%MODES' => \%MODES, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub mode_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mode_check: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my ($got, @want) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my $g = $MODES{$got} // croak "Invalid mode: $got"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$MODES{$got} // croak("Invalid mode: $got")
MC/DC0%0/1
$MODES{$got} // croak("Invalid mode: $got")
$MODES{$got}
Truth table0%0/2
A
A= $MODES{$got}
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | for my $want (@want) { | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $w = $MODES{$want} // croak "Invalid mode: $want"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$MODES{$want} // croak("Invalid mode: $want")
MC/DC0%0/1
$MODES{$want} // croak("Invalid mode: $want")
$MODES{$want}
Truth table0%0/2
A
A= $MODES{$want}
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | return 1 if $g == $w; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub _get_mode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_mode: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $run = $params{run}; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $mode = $params{mode}; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | croak "must specify either 'mode' or 'run'" unless $run || $mode; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$run or $mode
MC/DC0%0/2
$run or $mode
$run
$mode
Truth table0%0/3
A or B
A= $runB= $mode
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | $mode //= $run->mode if $run; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mode //= $run->mode
MC/DC0%0/2
$mode //= $run->mode
$mode
$run->mode
Truth table0%0/3
A //= B
A= $modeB= $run->mode
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | # Normalize | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | $mode = $MODES{$mode} // $mode; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$MODES{$mode} // $mode
MC/DC0%0/2
$MODES{$mode} // $mode
$MODES{$mode}
$mode
Truth table0%0/3
A // B
A= $MODES{$mode}B= $mode
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | croak "Invalid mode: $mode" unless $mode =~ m/^\d+$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | return $mode; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub record_all_events { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
record_all_events: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $mode = _get_mode(%params); | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $job = $params{job}; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $fail = $params{fail}; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $is_harness_out = $params{is_harness_out}; | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | croak "must specify either 'job' or 'fail' and 'is_harness_out'" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$job or defined $fail and defined $is_harness_out
defined $fail and defined $is_harness_out
MC/DC0%0/3
$job or defined $fail and defined $is_harness_out
$job
defined $fail
defined $is_harness_out
Truth table0%0/4
A or B and C
A= $jobB= defined $failC= defined $is_harness_out
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | unless $job || (defined($fail) && defined($is_harness_out)); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | # Always true in complete mode | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return 1 if $mode >= $MODES{complete}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | # No events in summary | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | return 0 if $mode <= $MODES{summary}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | # Job 0 (harness output) is kept in all non-summary modes | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $is_harness_out //= $job->is_harness_out; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$is_harness_out //= $job->is_harness_out
MC/DC0%0/2
$is_harness_out //= $job->is_harness_out
$is_harness_out
$job->is_harness_out
Truth table0%0/3
A //= B
A= $is_harness_outB= $job->is_harness_out
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | return 1 if $is_harness_out; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | # QVF and QVFD are all events when failing | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $fail //= $job->fail; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fail //= $job->fail
MC/DC0%0/2
$fail //= $job->fail
$fail
$job->fail
Truth table0%0/3
A //= B
A= $failB= $job->fail
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | return 1 if $fail && $mode >= $MODES{qvf}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$fail and $mode >= $MODES{"qvf"}
MC/DC0%0/2
$fail and $mode >= $MODES{"qvf"}
$fail
$mode >= $MODES{"qvf"}
Truth table0%0/3
A and B
A= $failB= $mode >= $MODES{"qvf"}
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub record_subtest_events { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
record_subtest_events: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | return 1 if $params{record_all_events} //= record_all_events(%params); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$params{"record_all_events"} //= record_all_events(%params)
MC/DC0%0/2
$params{"record_all_events"} //= record_all_events(%params)
$params{"record_all_events"}
record_all_events(%params)
Truth table0%0/3
A //= B
A= $params{"record_all_events"}B= record_all_events(%params)
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $mode = _get_mode(%params); | |||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | return 1 if $mode >= $MODES{qvfds}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub event_in_mode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
event_in_mode: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | my $event = $params{event} or croak "'event' is required"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | my $record_all = $params{record_all_events} //= record_all_events(%params); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$params{"record_all_events"} //= record_all_events(%params)
MC/DC0%0/2
$params{"record_all_events"} //= record_all_events(%params)
$params{"record_all_events"}
record_all_events(%params)
Truth table0%0/3
A //= B
A= $params{"record_all_events"}B= record_all_events(%params)
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | return 1 if $record_all; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | # Only look for diag and similar for QVFD and higher | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $mode = _get_mode(%params); | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | return 0 unless $mode >= $MODES{qvfd}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my $cols = _get_event_columns($event); | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | return 1 if $mode == $MODES{qvfds} && $cols->{is_subtest} && $cols->{nested} == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$mode == $MODES{"qvfds"} and $cols->{"is_subtest"} and $cols->{"nested"} == 0
$mode == $MODES{"qvfds"} and $cols->{"is_subtest"}
MC/DC0%0/3
$mode == $MODES{"qvfds"} and $cols->{"is_subtest"} and $cols->{"nested"} == 0
$mode == $MODES{"qvfds"}
$cols->{"is_subtest"}
$cols->{"nested"} == 0
Truth table0%0/4
A and B and C
A= $mode == $MODES{"qvfds"}B= $cols->{"is_subtest"}C= $cols->{"nested"} == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | return 1 if $cols->{is_diag}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | return 1 if $cols->{is_harness}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | return 1 if $cols->{is_time}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub _get_event_columns { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_event_columns: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my ($event) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | return { $event->get_all_fields } if blessed($event) && $event->can('get_columns'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($event) and $event->can("get_columns")
MC/DC0%0/2
builtin::blessed($event) and $event->can("get_columns")
builtin::blessed($event)
$event->can("get_columns")
Truth table0%0/3
A and B
A= builtin::blessed($event)B= $event->can("get_columns")
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | return $event if (reftype($event) // '') eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
builtin::reftype($event) // ""
MC/DC0%0/1
builtin::reftype($event) // ""
builtin::reftype($event)
Truth table0%0/2
A
A= builtin::reftype($event)
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | croak "Invalid event: $event"; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||