File Coverage

blib/lib/TAP/Formatter/GitHubActions/Utils.pm
Criterion Covered Total %
statement 14 14 100.0
branch 1 2 50.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 20 21 95.2


line stmt bran cond sub pod time code
1             package TAP::Formatter::GitHubActions::Utils;
2              
3 3     3   25 use strict;
  3         6  
  3         102  
4 3     3   13 use warnings;
  3         5  
  3         150  
5 3     3   32 use v5.16;
  3         10  
6              
7             our @EXPORT_OK = qw(log_annotation_line);
8              
9             sub log_annotation_line {
10 35     35 1 343 my (%args) = @_;
11              
12 35         88 my $body = $args{body};
13 35         105 my $title = $args{title};
14              
15             # If title is given, write it, else just keep body
16 35 50       111 my $line = $title ? (
17             "::%s file=%s,line=%s,title=${title}::%s"
18             ) : (
19             "::%s file=%s,line=%s::%s"
20             );
21              
22 35         220 $body =~ s/\n/%0A/mg;
23              
24             return sprintf(
25             $line,
26 35         233 $args{type}, $args{filename}, $args{line}, $body
27             );
28             }
29              
30             1;
31             __END__