GitHubActions/ErrorGroup.pm

filter: Statementstmt 100% 49 / 49 Branchbran 100% 4 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 4 totaltotal 91.5% 65 / 71 CC 6 SCAR 5.6
CC
6
Cov
98%
as_markdown_summary
3.0
_initialize
2.0
add
2.0
CRAP 1.8
« GitHubActions.pm ↑ Summary GitHubActions/Utils.pm »
1 package TAP::Formatter::GitHubActions::ErrorGroup;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use v5.16;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use base 'TAP::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use TAP::Formatter::GitHubActions::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 my @ATTR;
9  
10 3 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 @ATTR = qw(line errors);
12 3 __PACKAGE__->mk_methods(@ATTR);
13 }
14  
15 42 ▶sub _initialize {
Subroutine _initialize: called CC=2 SCAR=7.0
16 42 my ($self, %args) = @_;
17  
18 42 $self->{line} = $args{line};
19 42 ▶ $self->{errors} = $args{errors} // [];
Condition50%1/2
$args{"errors"} // []
l!l
042
MC/DC0%0/1
$args{"errors"} // []
$args{"errors"}
Truth table50%1/2
A
A= $args{"errors"}
Aresult
11
00
20  
21 42 return $self;
22 }
23  
24 43 ▶sub add {
Subroutine add: called CC=2 SCAR=6.9
Pod undocumented
25 43 my ($self, @errors) = @_;
26 43 push @{$self->{errors}}, $_ for @errors;
27 43 return $self;
28 }
29  
30 1 ▶sub as_markdown_summary {
Subroutine as_markdown_summary: called CC=3 SCAR=11.0
Pod undocumented
31 1 my ($self) = @_;
32 1 my $summary = "";
33  
34 1 foreach my $error (@{$self->errors}) {
35 2 $summary .= sprintf(" - %s on line %d\n", $error->test_name, $error->line);
36  
37 2 ▶ if (my $context_message = $error->decorated_context_message('```', '```')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $context_message = $error->decorated_context_message("```", "```")) 1 1 2
38 1 $context_message =~ s/^/ /mg;
39 1 $summary .= $context_message;
40 1 $summary .= "\n";
41 }
42 }
43  
44 1 return $summary;
45 }
46  
47 32 ▶sub as_summary_hash {
Subroutine as_summary_hash: called CC=2 SCAR=6.9
Pod undocumented
48 32 my ($self) = @_;
49  
50 32 my $error_count = scalar @{$self->errors};
51 32 ▶ my $title = "$error_count failed test" . ($error_count > 1 ? 's' : '');
Branch: 1 branch
BranchTrueFalseTotal
$error_count > 1 ? : 3 29 32
52 32 my $body = join("\n\n", map { $_->as_plain_text } @{$self->errors});
53 32 chomp($body);
54  
55 return {
56 32 title => $title,
57 body => $body
58 };
59 }
60  
61  
62 31 ▶sub as_gha_summary_for {
Subroutine as_gha_summary_for: called CC=1 SCAR=0.0
Pod undocumented
63 31 my ($self, $test) = @_;
64 31 my $reduction = $self->as_summary_hash();
65  
66 my $log_line = TAP::Formatter::GitHubActions::Utils::log_annotation_line(
67 type => 'error',
68 filename => $test,
69 line => $self->line,
70 title => $reduction->{title},
71 body => $reduction->{body}
72 31 );
73  
74 31 return "$log_line\n";
75 }
76  
77 3 1;
78 __END__
« GitHubActions.pm ↑ Summary GitHubActions/Utils.pm »