| 1 | package Tapper::Test; | ||||||||||||||||||||
| 2 | # git description: v4.1.2-3-g0257452 | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 2 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||
| 5 | # ABSTRACT: Tapper - Utilities for Perl based Tapper testing | ||||||||||||||||||||
| 6 | 2 | $Tapper::Test::VERSION = '5.0.0'; | |||||||||||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 2 | ▶ | use 5.010; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 2 | ▶ | use Test::More; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 2 | ▶ | use Sys::Info; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 2 | ▶ | use Format::Human::Bytes; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 2 | ▶ | use parent 'Exporter'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 2 | our @EXPORT = qw/tapper_suite_meta tapper_section_meta/; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 0 | ▶ | sub _uname { | ||||||||||||||||||
|
Subroutine
_uname: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 20 | 0 | my $os = Sys::Info->new->os; | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | ▶ | my $osbase = | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 23 | $os->is_win ? "Windows" : | ||||||||||||||||||||
| 24 | $os->is_linux ? "Linux" : | ||||||||||||||||||||
| 25 | $os->is_bsd ? "BSD" : | ||||||||||||||||||||
| 26 | "UnknownOS"; | ||||||||||||||||||||
| 27 | 0 | my $uname = join (" ", | |||||||||||||||||||
| 28 | $osbase, | ||||||||||||||||||||
| 29 | $os->node_name, | ||||||||||||||||||||
| 30 | $os->name(long => 1, edition => 1), | ||||||||||||||||||||
| 31 | ~~localtime($os->build), | ||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||
| 33 | 0 | $uname .= " [Sys::Info]"; | |||||||||||||||||||
| 34 | 0 | return $uname; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | sub _hostname { | ||||||||||||||||||
|
Subroutine
_hostname: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 38 | 0 | my $hostname = Sys::Info->new->os->node_name; | |||||||||||||||||||
| 39 | 0 | return $hostname; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | ▶ | sub _osname { | ||||||||||||||||||
|
Subroutine
_osname: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 43 | 0 | my $os = Sys::Info->new->os; | |||||||||||||||||||
| 44 | 0 | my $osname = join (" ", | |||||||||||||||||||
| 45 | $os->name(edition => 1), | ||||||||||||||||||||
| 46 | $os->version, | ||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||
| 48 | 0 | return $osname; | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | ▶ | sub _cpuinfo { | ||||||||||||||||||
|
Subroutine
_cpuinfo: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 52 | 0 | return Sys::Info->new->device('CPU')->identify; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 0 | ▶ | sub _ram { | ||||||||||||||||||
|
Subroutine
_ram: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 56 | 0 | my %osmeta = Sys::Info->new->os->meta; | |||||||||||||||||||
| 57 | 0 | my $ram = Format::Human::Bytes::base2($osmeta{physical_memory_total}*1024); | |||||||||||||||||||
| 58 | 0 | return $ram; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | ▶ | sub _starttime_test_program { | ||||||||||||||||||
|
Subroutine
_starttime_test_program: not called CC=1 SCAR=2.2
| |||||||||||||||||||||
| 62 | 2 | ▶ | use POSIX qw(strftime setlocale); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 0 | my $old_loc = setlocale( &POSIX::LC_ALL ); | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 0 | setlocale( &POSIX::LC_ALL, "C" ); | |||||||||||||||||||
| 67 | 0 | my $starttime_test_program = strftime("%a, %d %b %Y %H:%M:%S %z", gmtime(time())); | |||||||||||||||||||
| 68 | 0 | setlocale( &POSIX::LC_ALL, $old_loc ); | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 0 | return $starttime_test_program; | |||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | sub _suite_name | ||||||||||||||||||||
| 74 | 1 | ▶ | { | ||||||||||||||||||
|
Subroutine
_suite_name: called CC=6 SCAR=25.5
| |||||||||||||||||||||
| 75 | 1 | my $build_paramfile = '_build/build_params'; | |||||||||||||||||||
| 76 | 1 | my $makefile = 'Makefile'; | |||||||||||||||||||
| 77 | 1 | my $distini = 'dist.ini'; | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 1 | ▶ | if (-e $build_paramfile ) | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 80 | { | ||||||||||||||||||||
| 81 | 0 | my $params = do $build_paramfile; | |||||||||||||||||||
| 82 | 0 | my $suite_name = $params->[2]->{dist_name}; | |||||||||||||||||||
| 83 | 0 | return $suite_name; | |||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | elsif (-e $makefile) | ||||||||||||||||||||
| 86 | { | ||||||||||||||||||||
| 87 | 1 | my $infile = $makefile; | |||||||||||||||||||
| 88 | 1 | ▶ | open my $F, "<", $infile or die "Cannot open $infile"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 89 | 1 | my ($suite_name) = grep { /^DISTNAME *=/ } <$F>; | |||||||||||||||||||
| 90 | 1 | $suite_name =~ s/^.*=\s*//; | |||||||||||||||||||
| 91 | 1 | chomp $suite_name; | |||||||||||||||||||
| 92 | 1 | return $suite_name; | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | elsif (-e $distini) | ||||||||||||||||||||
| 95 | { | ||||||||||||||||||||
| 96 | 0 | my $infile = $distini; | |||||||||||||||||||
| 97 | 0 | ▶ | open my $F, "<", $infile or die "Cannot open $infile"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 98 | 0 | my ($suite_name) = grep { /^name *=/ } <$F>; | |||||||||||||||||||
| 99 | 0 | $suite_name =~ s/^.*=\s*//; | |||||||||||||||||||
| 100 | 0 | chomp $suite_name; | |||||||||||||||||||
| 101 | 0 | return $suite_name; | |||||||||||||||||||
| 102 | } | ||||||||||||||||||||
| 103 | else | ||||||||||||||||||||
| 104 | { | ||||||||||||||||||||
| 105 | 0 | warn "Cannot access $build_paramfile or $makefile.\nPlease run perl Build.PL or perl Makefile.PL.\n"; | |||||||||||||||||||
| 106 | 0 | return undef; | |||||||||||||||||||
| 107 | } | ||||||||||||||||||||
| 108 | } | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | sub _suite_version | ||||||||||||||||||||
| 111 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
_suite_version: not called CC=6 SCAR=37.4
| |||||||||||||||||||||
| 112 | 0 | my $build_paramfile = '_build/build_params'; | |||||||||||||||||||
| 113 | 0 | my $makefile = 'Makefile'; | |||||||||||||||||||
| 114 | 0 | my $distini = 'dist.ini'; | |||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 0 | ▶ | if (-e $build_paramfile ) | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 117 | { | ||||||||||||||||||||
| 118 | 0 | my $params = do $build_paramfile; | |||||||||||||||||||
| 119 | 0 | my $suite_version; | |||||||||||||||||||
| 120 | 0 | ▶ | if (not ref $params->[2]->{dist_version}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 121 | 0 | $suite_version = $params->[2]->{dist_version}; | |||||||||||||||||||
| 122 | } else { | ||||||||||||||||||||
| 123 | 0 | $suite_version = $params->[2]->{dist_version}->{original}; | |||||||||||||||||||
| 124 | } | ||||||||||||||||||||
| 125 | 0 | return $suite_version; | |||||||||||||||||||
| 126 | } | ||||||||||||||||||||
| 127 | elsif (-e $makefile) | ||||||||||||||||||||
| 128 | { | ||||||||||||||||||||
| 129 | 0 | my $infile = $makefile; | |||||||||||||||||||
| 130 | 0 | ▶ | open my $F, "<", $infile or die "Cannot open $infile"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 131 | 0 | my ($suite_version) = grep { /^VERSION *=/ } <$F>; | |||||||||||||||||||
| 132 | 0 | $suite_version =~ s/^.*=\s*//; | |||||||||||||||||||
| 133 | 0 | chomp $suite_version; | |||||||||||||||||||
| 134 | 0 | return $suite_version; | |||||||||||||||||||
| 135 | } | ||||||||||||||||||||
| 136 | elsif (-e $distini) | ||||||||||||||||||||
| 137 | { | ||||||||||||||||||||
| 138 | 0 | return undef; | |||||||||||||||||||
| 139 | } | ||||||||||||||||||||
| 140 | else | ||||||||||||||||||||
| 141 | { | ||||||||||||||||||||
| 142 | 0 | warn "Cannot access $build_paramfile or $makefile.\nPlease run perl Build.PL or perl Makefile.PL\n"; | |||||||||||||||||||
| 143 | 0 | return undef; | |||||||||||||||||||
| 144 | } | ||||||||||||||||||||
| 145 | } | ||||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | sub _suite_type | ||||||||||||||||||||
| 148 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
_suite_type: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 149 | 0 | 'software'; # 'hardware', 'benchmark', 'os', 'unknown' | |||||||||||||||||||
| 150 | } | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | 0 | ▶ | sub _language_description { | ||||||||||||||||||
|
Subroutine
_language_description: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 153 | 0 | return "Perl $], $^X"; | |||||||||||||||||||
| 154 | } | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | 0 | ▶ | sub _reportgroup_arbitrary { $ENV{TAPPER_REPORT_GROUP} } | ||||||||||||||||||
|
Subroutine
_reportgroup_arbitrary: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 157 | 0 | ▶ | sub _reportgroup_testrun { $ENV{TAPPER_TESTRUN} } | ||||||||||||||||||
|
Subroutine
_reportgroup_testrun: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 158 | |||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | sub tapper_suite_meta | ||||||||||||||||||||
| 161 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
tapper_suite_meta: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||
| 162 | 0 | my %opts = @_; | |||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | 0 | ▶ | plan tests => 1 unless $opts{-suppress_plan}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 165 | 0 | pass("tapper-suite-meta"); | |||||||||||||||||||
| 166 | |||||||||||||||||||||
| 167 | 0 | ▶ | my $suite_name = $opts{suite_name} // _suite_name(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"suite_name"} // _suite_name()
MC/DC0%0/2
$opts{"suite_name"} // _suite_name()
$opts{"suite_name"}
_suite_name()
Truth table0%0/3
A // B
A= $opts{"suite_name"}B= _suite_name()
| |||||||||||||||||||||
| 168 | 0 | ▶ | my $suite_version = $opts{suite_version} // _suite_version(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"suite_version"} // _suite_version()
MC/DC0%0/2
$opts{"suite_version"} // _suite_version()
$opts{"suite_version"}
_suite_version()
Truth table0%0/3
A // B
A= $opts{"suite_version"}B= _suite_version()
| |||||||||||||||||||||
| 169 | 0 | ▶ | my $suite_type = $opts{suite_type} // _suite_type(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"suite_type"} // _suite_type()
MC/DC0%0/2
$opts{"suite_type"} // _suite_type()
$opts{"suite_type"}
_suite_type()
Truth table0%0/3
A // B
A= $opts{"suite_type"}B= _suite_type()
| |||||||||||||||||||||
| 170 | 0 | ▶ | my $hostname = $opts{hostname} // _hostname(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"hostname"} // _hostname()
MC/DC0%0/2
$opts{"hostname"} // _hostname()
$opts{"hostname"}
_hostname()
Truth table0%0/3
A // B
A= $opts{"hostname"}B= _hostname()
| |||||||||||||||||||||
| 171 | 0 | ▶ | my $reportgroup_arbitrary = $opts{reportgroup_arbitrary} // _reportgroup_arbitrary(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"reportgroup_arbitrary"} // _reportgroup_arbitrary()
MC/DC0%0/2
$opts{"reportgroup_arbitrary"} // _reportgroup_arbitrary()
$opts{"reportgroup_arbitrary"}
_reportgroup_arbitrary()
Truth table0%0/3
A // B
A= $opts{"reportgroup_arbitrary"}B= _reportgroup_arbitrary()
| |||||||||||||||||||||
| 172 | 0 | ▶ | my $reportgroup_testrun = $opts{reportgroup_testrun} // _reportgroup_testrun(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"reportgroup_testrun"} // _reportgroup_testrun()
MC/DC0%0/2
$opts{"reportgroup_testrun"} // _reportgroup_testrun()
$opts{"reportgroup_testrun"}
_reportgroup_testrun()
Truth table0%0/3
A // B
A= $opts{"reportgroup_testrun"}B= _reportgroup_testrun()
| |||||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | # to be used by TestSuite::* and Tapper::* modules | ||||||||||||||||||||
| 175 | |||||||||||||||||||||
| 176 | 0 | ▶ | print "# Tapper-reportgroup-arbitrary: $reportgroup_arbitrary\n" if $reportgroup_arbitrary; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 177 | 0 | ▶ | print "# Tapper-reportgroup-testrun: $reportgroup_testrun\n" if $reportgroup_testrun; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 178 | 0 | print "# Tapper-suite-name: $suite_name\n"; | |||||||||||||||||||
| 179 | 0 | print "# Tapper-suite-version: $suite_version\n"; | |||||||||||||||||||
| 180 | 0 | print "# Tapper-suite-type: $suite_type\n"; | |||||||||||||||||||
| 181 | 0 | print "# Tapper-machine-name: $hostname\n"; | |||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | 0 | tapper_section_meta(@_); | |||||||||||||||||||
| 184 | } | ||||||||||||||||||||
| 185 | |||||||||||||||||||||
| 186 | |||||||||||||||||||||
| 187 | sub tapper_section_meta | ||||||||||||||||||||
| 188 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
tapper_section_meta: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||
| 189 | 0 | my %opts = @_; | |||||||||||||||||||
| 190 | |||||||||||||||||||||
| 191 | 0 | ▶ | my $uname = $opts{uname} // _uname(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"uname"} // _uname()
MC/DC0%0/2
$opts{"uname"} // _uname()
$opts{"uname"}
_uname()
Truth table0%0/3
A // B
A= $opts{"uname"}B= _uname()
| |||||||||||||||||||||
| 192 | 0 | ▶ | my $osname = $opts{osname} // _osname(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"osname"} // _osname()
MC/DC0%0/2
$opts{"osname"} // _osname()
$opts{"osname"}
_osname()
Truth table0%0/3
A // B
A= $opts{"osname"}B= _osname()
| |||||||||||||||||||||
| 193 | 0 | ▶ | my $cpuinfo = $opts{cpuinfo} // _cpuinfo(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"cpuinfo"} // _cpuinfo()
MC/DC0%0/2
$opts{"cpuinfo"} // _cpuinfo()
$opts{"cpuinfo"}
_cpuinfo()
Truth table0%0/3
A // B
A= $opts{"cpuinfo"}B= _cpuinfo()
| |||||||||||||||||||||
| 194 | 0 | ▶ | my $ram = $opts{ram} // _ram(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"ram"} // _ram()
MC/DC0%0/2
$opts{"ram"} // _ram()
$opts{"ram"}
_ram()
Truth table0%0/3
A // B
A= $opts{"ram"}B= _ram()
| |||||||||||||||||||||
| 195 | 0 | ▶ | my $starttime_test_program = $opts{starttime_test_program} // _starttime_test_program(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"starttime_test_program"} // _starttime_test_program()
MC/DC0%0/2
$opts{"starttime_test_program"} // _starttime_test_program()
$opts{"starttime_test_program"}
_starttime_test_program()
Truth table0%0/3
A // B
A= $opts{"starttime_test_program"}B= _starttime_test_program()
| |||||||||||||||||||||
| 196 | 0 | ▶ | my $language_description = $opts{language_description} // _language_description(); | ||||||||||||||||||
|
Condition0%0/3
$opts{"language_description"} // _language_description()
MC/DC0%0/2
$opts{"language_description"} // _language_description()
$opts{"language_description"}
_language_description()
Truth table0%0/3
A // B
A= $opts{"language_description"}B= _language_description()
| |||||||||||||||||||||
| 197 | 0 | my $section = $opts{section}; | |||||||||||||||||||
| 198 | |||||||||||||||||||||
| 199 | # to be used by TestSuite::* and Tapper::* modules | ||||||||||||||||||||
| 200 | |||||||||||||||||||||
| 201 | 0 | print "# Tapper-language-description: $language_description\n"; | |||||||||||||||||||
| 202 | 0 | print "# Tapper-uname: $uname\n"; | |||||||||||||||||||
| 203 | 0 | print "# Tapper-osname: $osname\n"; | |||||||||||||||||||
| 204 | 0 | print "# Tapper-cpuinfo: $cpuinfo\n"; | |||||||||||||||||||
| 205 | 0 | print "# Tapper-ram: $ram\n"; | |||||||||||||||||||
| 206 | 0 | print "# Tapper-starttime-test-program: $starttime_test_program\n"; | |||||||||||||||||||
| 207 | 0 | ▶ | print "# Tapper-section: $section\n" if $section; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 208 | } | ||||||||||||||||||||
| 209 | |||||||||||||||||||||
| 210 | |||||||||||||||||||||
| 211 | |||||||||||||||||||||
| 212 | 2 | 1; # End of Tapper::Test | |||||||||||||||||||
| 213 | |||||||||||||||||||||
| 214 | __END__ | ||||||||||||||||||||