GitHubActions/Error.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 100% 53 / 53 CC 3 SCAR 2.9
CC
3
Cov
100%
from_output
2.0
decorated_context_message
2.0
BEGIN
1.0
CRAP 1.3
« GitHubActions/Utils.pm ↑ Summary GitHubActions/ErrorAggregate.pm »
1 package TAP::Formatter::GitHubActions::Error;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use v5.16;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use base 'TAP::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 my @ATTR;
9  
10 4 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 @ATTR = qw(test_name filename line context_msg );
12 4 __PACKAGE__->mk_methods(@ATTR);
13 }
14  
15 4 my $TRIPHASIC_REGEX = qr/
16 \s*
17 (?<test_name> # Test header
18 Failed\stest
19 (?:\s*'[^']+')? # Test name [usually last param in an assertion, optional]
20 )
21 \s*
22 at\s(?<filename>.+) # Location: File
23 \s+
24 line\s(?<line>\d+)\. # Location: Line
25 (\n)?
26 (?<context_msg>[\w\W]*) # Any additional content
27 /mx;
28  
29 4 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
30 4 TRIPHASIC_REGEX => $TRIPHASIC_REGEX,
31 4 };
32  
33 36 ▶sub from_output {
Subroutine from_output: called CC=2 SCAR=6.9
Pod documented
34 36 my ($class, $output) = @_;
35  
36 36 ▶ return undef unless $output =~ qr/$TRIPHASIC_REGEX/m;
Branch: 1 branch
BranchTrueFalseTotal
unless $output =~ qr/$TRIPHASIC_REGEX/mu 1 35 36
37  
38 return $class->new(
39 line => $+{line},
40 filename => $+{filename},
41 test_name => $+{test_name},
42 context_msg => $+{context_msg}
43 35 );
44 }
45  
46 51 ▶sub _initialize {
Subroutine _initialize: called CC=1 SCAR=0.0
47 51 my ($self, %args) = @_;
48  
49 51 $self->{test_name} = $args{test_name};
50 51 $self->{filename} = $args{filename};
51 51 $self->{line} = $args{line};
52 51 $self->{context_msg} = $args{context_msg};
53  
54 51 return $self;
55 }
56  
57 45 ▶sub decorated_context_message {
Subroutine decorated_context_message: called CC=2 SCAR=6.9
Pod documented
58 45 my ($self, $pre, $post) = @_;
59  
60 45 ▶ return unless $self->{context_msg};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"context_msg"} 11 34 45
61  
62 return join("\n",
63 34 grep { $_ } ($pre, $self->context_msg, $post)
64 );
65 }
66  
67 38 ▶sub as_plain_text {
Subroutine as_plain_text: called CC=1 SCAR=0.0
Pod documented
68 38 my ($self) = @_;
69 38 my @components = (
70 $self->test_name,
71 $self->decorated_context_message(
72 '--- CAPTURED CONTEXT ---',
73 '--- END OF CONTEXT ---')
74 );
75 38 return join("\n", grep { $_ } @components);
76 }
77  
78 4 1;
79 __END__
« GitHubActions/Utils.pm ↑ Summary GitHubActions/ErrorAggregate.pm »