Tapper/Schema/TestrunDB/Result/Report.pm

filter: Statementstmt 82.7% 67 / 81 Branchbran 44.4% 8 / 18 Conditioncond 42.8% 3 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 81.8% 9 / 11 Podpod 100% 5 / 5 totaltotal 73.0% 92 / 126 CC 14 SCAR 18.6
CC
14
Cov
74%
get_cached_tapdom
11.4
sections_cpuinfo
6.0
sections_osname
6.0
CRAP 6.4
« Tapper/Schema/TestrunDB/Result/ReportgroupTestrunStats.pm ↑ Summary Tapper/Schema/TestrunDB/ResultSet/TestrunScheduling.pm »
1 package Tapper::Schema::TestrunDB::Result::Report;
2 10 our $AUTHORITY = 'cpan:TAPPER';
3 10 $Tapper::Schema::TestrunDB::Result::Report::VERSION = '5.0.12';
4 # ABSTRACT: Tapper - containing reports
5  
6 10 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 10 ▶use parent 'DBIx::Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 10 ▶use Tapper::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 10 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 10 __PACKAGE__->load_components(qw(InflateColumn::DateTime TimeStamp Core));
16 10 __PACKAGE__->table("report");
17 10 __PACKAGE__->add_columns
18 (
19 "id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_auto_increment => 1, },
20 "suite_id", { data_type => "INT", default_value => undef, is_nullable => 1, size => 11, is_foreign_key => 1, },
21 "suite_version", { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 255, },
22 "reportername", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 255, },
23 "peeraddr", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 255, },
24 "peerport", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 255, },
25 "peerhost", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 255, },
26 #
27 # tap parse result and its human interpretation
28 #
29 "successgrade", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 10, },
30 "reviewed_successgrade", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 10, },
31 #
32 # tap parse results
33 #
34 "total", { data_type => "INT", default_value => undef, is_nullable => 1, size => 10, },
35 "failed", { data_type => "INT", default_value => undef, is_nullable => 1, size => 10, },
36 "parse_errors", { data_type => "INT", default_value => undef, is_nullable => 1, size => 10, },
37 "passed", { data_type => "INT", default_value => undef, is_nullable => 1, size => 10, },
38 "skipped", { data_type => "INT", default_value => undef, is_nullable => 1, size => 10, },
39 "todo", { data_type => "INT", default_value => undef, is_nullable => 1, size => 10, },
40 "todo_passed", { data_type => "INT", default_value => undef, is_nullable => 1, size => 10, },
41 "success_ratio", { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 20, },
42 #
43 "starttime_test_program", { data_type => "DATETIME", default_value => undef, is_nullable => 1, },
44 "endtime_test_program", { data_type => "DATETIME", default_value => undef, is_nullable => 1, },
45 #
46 "machine_name", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 255, },
47 "machine_description", { data_type => "TEXT", default_value => "", is_nullable => 1, },
48 #
49 "created_at", { data_type => "DATETIME", default_value => undef, is_nullable => 0, set_on_create => 1, },
50 "updated_at", { data_type => "DATETIME", default_value => undef, is_nullable => 0, set_on_create => 1, set_on_update => 1, },
51 );
52  
53 10 __PACKAGE__->set_primary_key("id");
54  
55 10 __PACKAGE__->belongs_to ( suite => 'Tapper::Schema::TestrunDB::Result::Suite', { 'foreign.id' => 'self.suite_id' }, { 'join_type' => 'LEFT OUTER' });
56 10 __PACKAGE__->might_have ( reportgrouparbitrary => 'Tapper::Schema::TestrunDB::Result::ReportgroupArbitrary', { 'foreign.report_id' => 'self.id' }, { 'join_type' => 'LEFT OUTER' });
57 10 __PACKAGE__->might_have ( reportgrouptestrun => 'Tapper::Schema::TestrunDB::Result::ReportgroupTestrun', { 'foreign.report_id' => 'self.id' }, { 'join_type' => 'LEFT OUTER' });
58 10 __PACKAGE__->might_have ( tap => 'Tapper::Schema::TestrunDB::Result::Tap', { 'foreign.report_id' => 'self.id' }, { 'join_type' => 'LEFT OUTER' });
59  
60 10 __PACKAGE__->has_many ( comments => 'Tapper::Schema::TestrunDB::Result::ReportComment', { 'foreign.report_id' => 'self.id' });
61 10 __PACKAGE__->has_many ( topics => 'Tapper::Schema::TestrunDB::Result::ReportTopic', { 'foreign.report_id' => 'self.id' });
62 10 __PACKAGE__->has_many ( files => 'Tapper::Schema::TestrunDB::Result::ReportFile', { 'foreign.report_id' => 'self.id' });
63 10 __PACKAGE__->has_many ( reportsections => 'Tapper::Schema::TestrunDB::Result::ReportSection', { 'foreign.report_id' => 'self.id' });
64  
65  
66  
67 sub sqlt_deploy_hook
68 8 ▶{
Subroutine sqlt_deploy_hook: called CC=1 SCAR=0.0
Pod documented
69 8 my ($self, $sqlt_table) = @_;
70 8 $sqlt_table->add_index(name => 'report_idx_machine_name', fields => ['machine_name']);
71 # $sqlt_table->add_index(name => 'report_idx_suite_id', fields => ['suite_id']); # implicitely done(?)
72 8 $sqlt_table->add_index(name => 'report_idx_created_at', fields => ['created_at']);
73 }
74  
75 #sub suite_name { shift->suite->name }
76 #sub suite_name { my ($self, $arg) = @_; return $self->search({ "suite.name" => $arg })};
77  
78  
79  
80 sub sections_cpuinfo
81 0 ▶{
Subroutine sections_cpuinfo: not called CC=2 SCAR=17.9
Pod documented
82 0 my ($self) = @_;
83 0 my $sections = $self->reportsections;
84 0 my @cpus;
85 0 ▶ while (my $section = $sections->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $section = $sections->next) 0 0 0
86 0 push @cpus, $section->cpuinfo;
87 }
88 0 return @cpus;
89 }
90  
91  
92 sub sections_osname
93 0 ▶{
Subroutine sections_osname: not called CC=2 SCAR=17.9
Pod documented
94 0 my ($self) = @_;
95 0 my $sections = $self->reportsections;
96 0 my @cpus;
97 0 ▶ while (my $section = $sections->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $section = $sections->next) 0 0 0
98 0 push @cpus, $section->osname;
99 }
100 0 return @cpus;
101 }
102  
103  
104 sub some_meta_available
105 2 ▶{
Subroutine some_meta_available: called CC=3 SCAR=11.0
Pod documented
106 2 my ($self) = @_;
107  
108 2 my $sections = $self->reportsections;
109 2 ▶ while (my $section = $sections->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $section = $sections->next) 1 1 2
110 1 ▶ return 1 if $section->some_meta_available;
Branch: 1 branch
BranchTrueFalseTotal
if $section->some_meta_available 1 0 1
111 }
112 1 return 0;
113 }
114  
115  
116 sub get_cached_tapdom
117 1 ▶{
Subroutine get_cached_tapdom: called CC=10 SCAR=24.3
Pod documented
118 1 my ($r) = @_;
119  
120 1 my $cache_tapdom_in_db = Tapper::Config->subconfig->{cache_tapdom_in_db};
121  
122 1 require Tapper::TAP::Harness;
123 1 require TAP::DOM;
124  
125 1 my $TAPVERSION = "TAP Version 13";
126 1 my $tapdom_sections = [];
127  
128 1 my $report = $r->result_source->schema->resultset('Report')->find($r->id);
129 1 my $tapdom_str;
130 1 ▶ $tapdom_str = $report->tap->tapdom if $cache_tapdom_in_db;
Branch: 1 branch
BranchTrueFalseTotal
if $cache_tapdom_in_db 1 0 1
131  
132 # set TAPPER_FORCE_NEW_TAPDOM to force the re-generation of the TAP DOM, e.g. when the TAP::DOM module changes
133 1 ▶ if ($tapdom_str and not -e '/tmp/TAPPER_FORCE_NEW_TAPDOM')
Branch: 1 branch
BranchTrueFalseTotal
if ($tapdom_str and not -e '/tmp/TAPPER_FORCE_NEW_TAPDOM') { } 0 1 1
Condition33%1/3
$tapdom_str and not -e "/tmp/TAPPER_FORCE_NEW_TAPDOM"
!ll&&!rl&&r
100
MC/DC0%0/2
$tapdom_str and not -e "/tmp/TAPPER_FORCE_NEW_TAPDOM"
$tapdom_str not -e "/tmp/TAPPER_FORCE_NEW_TAPDOM"
Truth table33%1/3
A and not(B)
A= $tapdom_strB= not -e "/tmp/TAPPER_FORCE_NEW_TAPDOM"
ABresult
0X0
100
111
134 {
135 #say STDERR "EVAL ", $r->id;
136 0 eval '$tapdom_sections = my '.$tapdom_str; ## no critic (ProhibitStringyEval)
137 }
138 else
139 {
140 # say STDERR "RUN TAPPER::TAP::HARNESS ", $r->id;
141  
142 1 my $report_tap = $report->tap->tap;
143 1 ▶ my $tap_is_archive = $report->tap->tap_is_archive || 0;
Condition50%1/2
$report->tap->tap_is_archive || 0
l!l
01
MC/DC0%0/1
$report->tap->tap_is_archive || 0
$report->tap->tap_is_archive
Truth table50%1/2
A
A= $report->tap->tap_is_archive
Aresult
11
00
144  
145 # We got "Out of memory!" with monster TAP reports.
146 1 ▶ if (length $report_tap > 2_000_000) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $report_tap > 2000000) { } 0 1 1
147 0 warn "Ignore report ".$r->id." due to too large TAP. ";
148 }
149 else
150 {
151 1 my $harness = new Tapper::TAP::Harness( tap => $report_tap,
152 tap_is_archive => $tap_is_archive );
153 1 $harness->evaluate_report();
154 #print STDERR Dumper($harness->parsed_report);
155 1 foreach (@{$harness->parsed_report->{tap_sections}})
156 {
157 #print STDERR ".";
158 1 ▶ my $rawtap = $_->{raw} || '';
Condition50%1/2
$_->{'raw'} || ''
l!l
10
MC/DC0%0/1
$_->{'raw'} || ''
$_->{'raw'}
Truth table50%1/2
A
A= $_->{'raw'}
Aresult
11
00
159 #say STDERR "x"x100, "\n", $rawtap, "\n", "x"x 100;
160 1 ▶ $rawtap = $TAPVERSION."\n".$rawtap unless $rawtap =~ /^TAP Version/msi;
Branch: 1 branch
BranchTrueFalseTotal
unless $rawtap =~ /^TAP Version/ism 1 0 1
161 #say STDERR length($rawtap);
162 1 my $tapdom = new TAP::DOM ( tap => $rawtap,
163 noempty_tap => 1,
164 ignore => [qw( raw as_string )],
165 ignorelines => qr/^\#\# /, # mostly used in oprofile
166 );
167 push @$tapdom_sections, { section => { $_->{section_name} => { tap => $tapdom,
168 meta => $_->{section_meta},
169 }
170 }
171 1 };
172 }
173 1 $tapdom_str = Dumper($tapdom_sections);
174 1 ▶ if ($cache_tapdom_in_db) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cache_tapdom_in_db) 1 0 1
175 1 $report->tap->tapdom( $tapdom_str );
176 #say STDERR "new report: ", Dumper($report);
177 1 $report->tap->update;
178 1 $report->update;
179 }
180 }
181 }
182 #print STDERR ".\n";
183 1 return $tapdom_sections;
184 }
185  
186 10 1;
187  
188 __END__
« Tapper/Schema/TestrunDB/Result/ReportgroupTestrunStats.pm ↑ Summary Tapper/Schema/TestrunDB/ResultSet/TestrunScheduling.pm »