« lib/Test2/Harness/UI/Controller/Interactions.pm
↑ Summary
lib/Test2/Harness/UI/Controller/Upload.pm »
| 1 | package Test2::Harness::UI::Schema::Result::Job; | ||||||||||||||||||||
| 2 | 2 | ▶ | use utf8; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 2 | ▶ | use Test2::Harness::UI::Util::ImportModes qw/record_all_events mode_check/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 2 | ▶ | use Carp qw/confess/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 2 | ▶ | confess "You must first load a Test2::Harness::UI::Schema::NAME module" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 10 | unless $Test2::Harness::UI::Schema::LOADED; | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 2 | our $VERSION = '0.000150'; | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 2 | __PACKAGE__->inflate_column( | |||||||||||||||||||
| 15 | parameters => { | ||||||||||||||||||||
| 16 | inflate => DBIx::Class::InflateColumn::Serializer::JSON->get_unfreezer('parameters', {}), | ||||||||||||||||||||
| 17 | deflate => DBIx::Class::InflateColumn::Serializer::JSON->get_freezer('parameters', {}), | ||||||||||||||||||||
| 18 | }, | ||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | ▶ | sub file { | ||||||||||||||||||
|
Subroutine
file: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 22 | 0 | my $self = shift; | |||||||||||||||||||
| 23 | 0 | my %cols = $self->get_all_fields; | |||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 0 | ▶ | return $cols{file} if exists $cols{file}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 0 | ▶ | return $cols{filename} if exists $cols{filename}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | my $test_file = $self->test_file or return undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | 0 | return $test_file->filename; | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | ▶ | sub shortest_file { | ||||||||||||||||||
|
Subroutine
shortest_file: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 33 | 0 | my $self = shift; | |||||||||||||||||||
| 34 | 0 | ▶ | my $file = $self->file or return undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | return $1 if $file =~ m{([^/]+)$}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | 0 | return $file; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | ▶ | sub short_file { | ||||||||||||||||||
|
Subroutine
short_file: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 41 | 0 | my $self = shift; | |||||||||||||||||||
| 42 | 0 | ▶ | my $file = $self->file or return undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | return $1 if $file =~ m{/(t2?/.*)$}i; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | 0 | ▶ | return $1 if $file =~ m{([^/\\]+\.(?:t2?|pl))$}i; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 46 | 0 | return $file; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 2 | my %COMPLETE_STATUS = (complete => 1, failed => 1, canceled => 1, broken => 1); | |||||||||||||||||||
| 50 | 0 | ▶ | sub complete { return $COMPLETE_STATUS{$_[0]->status} // 0 } | ||||||||||||||||||
|
Subroutine
complete: not called CC=2 SCAR=17.9
Pod
undocumented
Condition0%0/2
$COMPLETE_STATUS{$_[0]->status} // 0
MC/DC0%0/1
$COMPLETE_STATUS{$_[0]->status} // 0
$COMPLETE_STATUS{$_[0]->status}
Truth table0%0/2
A
A= $COMPLETE_STATUS{$_[0]->status}
| |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 0 | ▶ | sub sig { | ||||||||||||||||||
|
Subroutine
sig: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 53 | 0 | my $self = shift; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | return join ";" => ( | ||||||||||||||||||||
| 56 | 0 | ▶ | (map {$self->$_ // ''} qw/status pass_count fail_count name file fail/), | ||||||||||||||||||
|
Condition0%0/2
$self->$_ // ""
MC/DC0%0/1
$self->$_ // ""
$self->$_
Truth table0%0/2
A
A= $self->$_
| |||||||||||||||||||||
| 57 | 0 | ▶ | (map {length($self->$_ // '')} qw/parameters/), | ||||||||||||||||||
|
Condition0%0/2
$self->$_ // ""
MC/DC0%0/1
$self->$_ // ""
$self->$_
Truth table0%0/2
A
A= $self->$_
| |||||||||||||||||||||
| 58 | ($self->job_fields->count), | ||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | sub short_job_fields { | ||||||||||||||||||
|
Subroutine
short_job_fields: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 63 | 0 | my $self = shift; | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | ▶ | return [ map { my $d = +{$_->get_all_fields}; $d->{data} = $d->{has_data} ? \'1' : \'0'; $d } $self->job_fields->search(undef, { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | remove_columns => ['data'], | ||||||||||||||||||||
| 67 | '+select' => ['data IS NOT NULL AS has_data'], | ||||||||||||||||||||
| 68 | '+as' => ['has_data'], | ||||||||||||||||||||
| 69 | })->all ]; | ||||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | ▶ | sub TO_JSON { | ||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 73 | 0 | my $self = shift; | |||||||||||||||||||
| 74 | 0 | my %cols = $self->get_all_fields; | |||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 0 | $cols{short_file} = $self->short_file; | |||||||||||||||||||
| 77 | 0 | $cols{shortest_file} = $self->shortest_file; | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | # Inflate | ||||||||||||||||||||
| 80 | 0 | $cols{parameters} = $self->parameters; | |||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 0 | $cols{fields} = $self->short_job_fields; | |||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 0 | return \%cols; | |||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 2 | my @GLANCE_FIELDS = qw{ exit_code fail fail_count job_key job_try retry name pass_count file status job_ord run_id }; | |||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 0 | ▶ | sub glance_data { | ||||||||||||||||||
|
Subroutine
glance_data: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 90 | 0 | my $self = shift; | |||||||||||||||||||
| 91 | 0 | my %cols = $self->get_all_fields; | |||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 0 | my %data; | |||||||||||||||||||
| 94 | 0 | @data{@GLANCE_FIELDS} = @cols{@GLANCE_FIELDS}; | |||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 0 | $data{file} = $self->file; | |||||||||||||||||||
| 97 | 0 | $data{short_file} = $self->short_file; | |||||||||||||||||||
| 98 | 0 | $data{shortest_file} = $self->shortest_file; | |||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | 0 | $data{fields} = $self->short_job_fields; | |||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 0 | return \%data; | |||||||||||||||||||
| 103 | } | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 0 | ▶ | sub normalize_to_mode { | ||||||||||||||||||
|
Subroutine
normalize_to_mode: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||
| 106 | 0 | my $self = shift; | |||||||||||||||||||
| 107 | 0 | my %params = @_; | |||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | 0 | ▶ | my $mode = $params{mode} // $self->run->mode; | ||||||||||||||||||
|
Condition0%0/3
$params{"mode"} // $self->run->mode
MC/DC0%0/2
$params{"mode"} // $self->run->mode
$params{"mode"}
$self->run->mode
Truth table0%0/3
A // B
A= $params{"mode"}B= $self->run->mode
| |||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | # No need to purge anything | ||||||||||||||||||||
| 112 | 0 | ▶ | return if record_all_events(mode => $mode, job => $self); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 113 | 0 | ▶ | return if mode_check($mode, 'complete'); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | 0 | ▶ | if (mode_check($mode, 'summary', 'qvf')) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 116 | 0 | my $has_binary = $self->events->search({has_binary => 1}); | |||||||||||||||||||
| 117 | 0 | ▶ | while (my $e = $has_binary->next()) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 118 | 0 | $e->binaries->delete; | |||||||||||||||||||
| 119 | 0 | $e->delete; | |||||||||||||||||||
| 120 | } | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | 0 | $self->events->delete; | |||||||||||||||||||
| 123 | 0 | return; | |||||||||||||||||||
| 124 | } | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 0 | my $query = { | |||||||||||||||||||
| 127 | is_diag => 0, | ||||||||||||||||||||
| 128 | is_harness => 0, | ||||||||||||||||||||
| 129 | is_time => 0, | ||||||||||||||||||||
| 130 | }; | ||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | 0 | ▶ | if (mode_check($mode, 'qvfds')) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 133 | 0 | $query->{'-not'} = {is_subtest => 1, nested => 0}; | |||||||||||||||||||
| 134 | } | ||||||||||||||||||||
| 135 | elsif(!mode_check($mode, 'qvfd')) { | ||||||||||||||||||||
| 136 | 0 | die "Unknown mode '$mode'"; | |||||||||||||||||||
| 137 | } | ||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | 0 | my $has_binary = $self->events->search({%$query, has_binary => 1}); | |||||||||||||||||||
| 140 | 0 | ▶ | while (my $e = $has_binary->next()) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 141 | 0 | $has_binary->binaries->delete; | |||||||||||||||||||
| 142 | 0 | $e->delete; | |||||||||||||||||||
| 143 | } | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | 0 | $self->events->search($query)->delete(); | |||||||||||||||||||
| 146 | } | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | 2 | 1; | |||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | __END__ | ||||||||||||||||||||