| 1 | ## no critic (RequireUseStrict) | ||||||||||||
| 2 | package Tapper::Producer::Temare; | ||||||||||||
| 3 | 2 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||
| 4 | # ABSTRACT: produce preconditions via temare | ||||||||||||
| 5 | 2 | $Tapper::Producer::Temare::VERSION = '5.0.1'; | |||||||||||
| 6 | 2 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 2 | ▶ | use File::Temp 'tempfile'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 2 | ▶ | use YAML 'LoadFile'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 2 | ▶ | use Tapper::Config; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | ▶ | use Try::Tiny; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | |||||||||||||
| 13 | 1 | ▶ | sub produce { | ||||||||||
|
Subroutine
produce: called CC=4 SCAR=16.4
Pod
documented
| |||||||||||||
| 14 | 1 | my ($self, $job, $produce) = @_; | |||||||||||
| 15 | |||||||||||||
| 16 | 1 | my ($fh, $file) = tempfile( UNLINK => 1 ); | |||||||||||
| 17 | |||||||||||||
| 18 | 2 | ▶ | use Data::Dumper; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 1 | my $temare_path=Tapper::Config->subconfig->{paths}{temare_path}; | |||||||||||
| 20 | |||||||||||||
| 21 | 1 | $ENV{PYTHONPATH}="$temare_path/src"; | |||||||||||
| 22 | 1 | my $subject = $produce->{subject}; | |||||||||||
| 23 | 1 | my $bitness = $produce->{bitness}; | |||||||||||
| 24 | 1 | my $host = $job->host->name; | |||||||||||
| 25 | 1 | $ENV{TAPPER_TEMARE} = $file; | |||||||||||
| 26 | 1 | my $cmd="$temare_path/temare subjectprep $host $subject $bitness"; | |||||||||||
| 27 | 1 | my $precondition = qx($cmd); | |||||||||||
| 28 | 1 | ▶ | if ($?) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | 0 | my $error_msg = "Temare error.\n"; | |||||||||||
| 30 | 0 | $error_msg .= "Error code: $?\n"; | |||||||||||
| 31 | 0 | $error_msg .= "Error message: $precondition\n"; | |||||||||||
| 32 | 0 | die $error_msg; | |||||||||||
| 33 | } | ||||||||||||
| 34 | |||||||||||||
| 35 | 1 | ▶ | my $config = try {LoadFile($file)} catch { die "Error occured while loading precondition $precondition:\n$_"}; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 36 | 0 | close $fh; | |||||||||||
| 37 | 0 | ▶ | unlink $file if -e $file; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 38 | 0 | ▶ | my $topic = $config->{subject} || 'Misc'; | ||||||||||
|
Condition0%0/2
$config->{'subject'} || 'Misc'
MC/DC0%0/1
$config->{'subject'} || 'Misc'
$config->{'subject'}
Truth table0%0/2
A
A= $config->{'subject'}
| |||||||||||||
| 39 | return { | ||||||||||||
| 40 | 0 | topic => $topic, | |||||||||||
| 41 | precondition_yaml => $precondition | ||||||||||||
| 42 | }; | ||||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | 2 | 1; | |||||||||||
| 46 | |||||||||||||
| 47 | __END__ | ||||||||||||