lib/Test2/Harness/UI/Schema/Overlay/Job.pm

filter: Statementstmt 25.3% 21 / 83 Branchbran 2.9% 1 / 34 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 35.7% 5 / 14 Podpod 0.0% 0 / 9 totaltotal 17.5% 27 / 154 CC 21 SCAR 34.5
CC
21
Cov
17%
normalize_to_mode
90.0
file
20.0
short_file
20.0
CRAP 31.6
« 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
BranchTrueFalseTotal
unless $Test2::Harness::UI::Schema::LOADED 0 2 2
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
BranchTrueFalseTotal
if exists $cols{"file"} 0 0 0
26 0 ▶ return $cols{filename} if exists $cols{filename};
Branch: 1 branch
BranchTrueFalseTotal
if exists $cols{"filename"} 0 0 0
27  
28 0 ▶ my $test_file = $self->test_file or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $test_file = $self->test_file or return undef 0 0 0
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
BranchTrueFalseTotal
my $file = $self->file or return undef 0 0 0
35  
36 0 ▶ return $1 if $file =~ m{([^/]+)$};
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ m[([^/]+)$] 0 0 0
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
BranchTrueFalseTotal
my $file = $self->file or return undef 0 0 0
43  
44 0 ▶ return $1 if $file =~ m{/(t2?/.*)$}i;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ m[/(t2?/.*)$]i 0 0 0
45 0 ▶ return $1 if $file =~ m{([^/\\]+\.(?:t2?|pl))$}i;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ m(([^/\\]+\.(?:t2?|pl))$)i 0 0 0
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
l!l
00
MC/DC0%0/1
$COMPLETE_STATUS{$_[0]->status} // 0
$COMPLETE_STATUS{$_[0]->status}
Truth table0%0/2
A
A= $COMPLETE_STATUS{$_[0]->status}
Aresult
11
00
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->$_ // ""
l!l
00
MC/DC0%0/1
$self->$_ // ""
$self->$_
Truth table0%0/2
A
A= $self->$_
Aresult
11
00
57 0 ▶ (map {length($self->$_ // '')} qw/parameters/),
Condition0%0/2
$self->$_ // ""
l!l
00
MC/DC0%0/1
$self->$_ // ""
$self->$_
Truth table0%0/2
A
A= $self->$_
Aresult
11
00
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
BranchTrueFalseTotal
$d->{'has_data'} ? : 0 0 0
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
l!l&&r!l&&!r
000
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
ABresult
1X1
011
000
110  
111 # No need to purge anything
112 0 ▶ return if record_all_events(mode => $mode, job => $self);
Branch: 1 branch
BranchTrueFalseTotal
if record_all_events("mode", $mode, "job", $self) 0 0 0
113 0 ▶ return if mode_check($mode, 'complete');
Branch: 1 branch
BranchTrueFalseTotal
if mode_check($mode, "complete") 0 0 0
114  
115 0 ▶ if (mode_check($mode, 'summary', 'qvf')) {
Branch: 1 branch
BranchTrueFalseTotal
if (mode_check($mode, "summary", "qvf")) 0 0 0
116 0 my $has_binary = $self->events->search({has_binary => 1});
117 0 ▶ while (my $e = $has_binary->next()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $has_binary->next) 0 0 0
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
BranchTrueFalseTotal
if (mode_check($mode, 'qvfds')) { } 0 0 0
elsif (not mode_check($mode, 'qvfd')) { } 0 0 0
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
BranchTrueFalseTotal
if (my $e = $has_binary->next) 0 0 0
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__
« lib/Test2/Harness/UI/Controller/Interactions.pm ↑ Summary lib/Test2/Harness/UI/Controller/Upload.pm »