blib/script/tsarchivelog.pl untested

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 89 CC 1 SCAR 6.9
CC
1
Cov
0%
compose_log_file_name
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 use strict;
3  
4 use File::Spec::Functions;
5 use FindBin;
6 use lib catdir($FindBin::Bin, 'lib');
7 use lib catdir($FindBin::Bin, updir(), 'lib');
8  
9 use Test::Smoke::App::Options;
10 use Test::Smoke::App::SmokePerl;
11 use File::Copy;
12 use File::Spec;
13 use JSON;
14 use Path::Tiny ();
15 use POSIX ();
16  
17  
18 my $app = Test::Smoke::App::SmokePerl->new(
19 Test::Smoke::App::Options->smokeperl_config()
20 );
21  
22 if (my $error = $app->configfile_error) {
23 die "$error\n";
24 }
25  
26 my $lfile = $app->option('lfile');
27 die "Could not locate smokecurrent.log" unless -f $lfile;
28  
29 my $adir = $app->option('adir');
30 die "Could not locate logs/smokecurrent directory" unless -d $adir;
31  
32 my $jsnfile = File::Spec->catfile($app->option('ddir'), $app->option('jsnfile'));
33 die "Could not locate mktest.json" unless -f $jsnfile;
34 my $log_file = compose_log_file_name($adir, $jsnfile);
35  
36 my $localtime = POSIX::strftime("[%Y-%m-%d %H:%M:%S%z] ", localtime);
37  
38 my $success = copy($lfile => $log_file);
39 if (! $success) {
40 warn($localtime, "Failed to cp($lfile,$log_file): $!");
41 }
42 else {
43 open my $OVERALL_LOG, '>>', $log_file or die "Could not open $log_file for appending: $!";
44 print $OVERALL_LOG $localtime, "Copy($lfile, $log_file): ok\n";
45 close $OVERALL_LOG or die "Could not close $log_file after writing: $!";
46 }
47  
48  
49 sub compose_log_file_name {
50 my ($adir, $jsnfile) = @_;
51 my $utf8_encoded_json_text = Path::Tiny::path($jsnfile)->slurp_utf8;
52 my $config = decode_json($utf8_encoded_json_text);
53 my $SHA = $config->{sysinfo}->{git_id};
54 return File::Spec->catfile($adir, "log${SHA}.log");
55 }