line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tapper::CLI::Utils; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TAPPER'; |
3
|
|
|
|
|
|
|
$Tapper::CLI::Utils::VERSION = '5.0.6'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
73129
|
use parent 'Exporter'; |
|
1
|
|
|
|
|
245
|
|
|
1
|
|
|
|
|
4
|
|
6
|
1
|
|
|
1
|
|
440
|
use Template; |
|
1
|
|
|
|
|
15897
|
|
|
1
|
|
|
|
|
23
|
|
7
|
1
|
|
|
1
|
|
355
|
use Tapper::Config; |
|
1
|
|
|
|
|
50971
|
|
|
1
|
|
|
|
|
37
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
10
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
329
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT_OK=qw(apply_macro gen_self_docu); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub apply_macro |
17
|
|
|
|
|
|
|
{ |
18
|
2
|
|
|
2
|
1
|
872
|
my ($macro_text, $substitutes, $given_includes) = @_; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
12
|
my @standard_includes = (Tapper::Config->subconfig->{paths}{testplan_path}, '.'); |
21
|
2
|
50
|
|
|
|
11
|
my $include_path_list = join ":", @standard_includes, @{$given_includes || []}; |
|
2
|
|
|
|
|
8
|
|
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
21
|
my $tt = Template->new({INCLUDE_PATH => $include_path_list, ABSOLUTE => 1}); |
24
|
2
|
|
|
|
|
18230
|
my $ttapplied; |
25
|
|
|
|
|
|
|
|
26
|
2
|
100
|
66
|
|
|
39
|
if ($macro_text =~ /\n/ or not -e $macro_text) { |
27
|
1
|
50
|
|
|
|
6
|
$tt->process(\$macro_text, $substitutes, \$ttapplied) or die $tt->error(); |
28
|
|
|
|
|
|
|
} else { |
29
|
1
|
50
|
|
|
|
16
|
$tt->process($macro_text, $substitutes, \$ttapplied) or die $tt->error(); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
41358
|
return $ttapplied; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub gen_self_docu |
37
|
|
|
|
|
|
|
{ |
38
|
0
|
|
|
0
|
0
|
|
my ($text) = @_; |
39
|
0
|
|
|
|
|
|
my @guide = grep { m/^###/ } split (qr/\n/, $text); |
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $self_docu = "Self-documentation:\n"; |
41
|
0
|
|
|
|
|
|
$self_docu.= join "\n", map { my $l = $_; $l =~ s/^###/ /; "$l\n" } @guide; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=pod |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=encoding UTF-8 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Tapper::CLI::Utils |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 apply_macro |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Process macros and substitute using Template::Toolkit. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
@param string - text or filename containing macros |
62
|
|
|
|
|
|
|
@param hashref - containing substitutions |
63
|
|
|
|
|
|
|
@optparam array ref - path to more include files |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
@return success - text with applied macros |
66
|
|
|
|
|
|
|
@return error - die with error string |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AUTHOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Advanced Micro Devices, Inc.. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This is free software, licensed under: |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |