| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Provenance manifest (provenance.json) of the binary release workflow. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # provenance.pl merge <META.json> <version> <parts-dir> <assets-dir> <tarball-dir> <run-attempt> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # -> the manifest on STDOUT, once the parts agree with plan.pl, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # artifact files and each other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # provenance.pl verify <provenance.json> <SHA256SUMS> <tag> <version> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # a release manifest whose assets are exactly the lines of SHA256SUMS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # provenance.pl artifact <META.json> <version> -> <name>-<version>.provenance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # The parts come from facts.sh (plan, smoke) and build-leg.sh provenance (build): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # one KEY=VALUE line per fact, printable ASCII, an empty value is null; only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # `binary` of a build part and `image_repo_digest` of a smoke part repeat. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # A failure prints one line per problem on STDERR, nothing on STDOUT, and exits 1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | package DzilBinary::Provenance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 44 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 44 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 44 | ▶ | use JSON::PP (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 44 | ▶ | use Digest::SHA (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 44 | ▶ | use File::Basename (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 44 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 43 | my $HERE = File::Spec->rel2abs(File::Basename::dirname(__FILE__)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 43 | ▶ | require(File::Spec->catfile($HERE, 'publish.pl')) unless defined &DzilBinary::Publish::read_meta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 43 | ▶ | require(File::Spec->catfile($HERE, 'plan.pl')) unless defined &DzilBinary::Plan::plan; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 43 | my @MACHINE = qw( os architecture abi kernel kernel_release ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | my %KEYS = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | plan => [qw( kind mode tag version_slot source_commit source_tag_object server_url repository run_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | run_attempt event ref sha caller_workflow_ref caller_workflow_sha workflow_repository workflow_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | workflow_ref workflow_commit bundle_ref_input bundle_source bundle_commit )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | build => [qw( kind platform runner container runner_image_os runner_image_version runner_os runner_arch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 215 | run_attempt bundle_commit ), (map { "build_$_" } @MACHINE), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | qw( perl_version perl_archname par_packer_version macosx_deployment_target binary )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | smoke => [qw( kind platform binary asset sha256 smoked runner runner_image_os runner_image_version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 215 | runner_os runner_arch run_attempt bundle_commit ), (map { "host_$_" } @MACHINE), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 43 | qw( image image_id image_platform image_repo_digest ), (map { "target_$_" } @MACHINE)], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 43 | my %REPEAT = (build => { binary => 1 }, smoke => { image_repo_digest => 1 }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 43 | my $COMMIT = qr/\A[0-9a-f]{40}\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 32 | ▶ | sub fail { print STDERR "$_\n" for @_; return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fail: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 4088 | ▶ | sub nul { return defined $_[0] && length $_[0] ? $_[0] : undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nul: called CC=3 SCAR=11.1
Branch: 1 branch
Condition66%2/3
defined $_[0] and length $_[0]
MC/DC50%1/2
defined $_[0] and length $_[0]
defined $_[0]
length $_[0]
Truth table66%2/3
A and B
A= defined $_[0]B= length $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 123 | ▶ | sub sha256_file { return Digest::SHA->new(256)->addfile($_[0], 'b')->hexdigest } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sha256_file: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 447 | ▶ | sub machine_of { my ($kv, $prefix) = @_; return { map { $_ => nul($kv->{"$prefix$_"}) } @MACHINE } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
machine_of: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 248 | ▶ | sub runner_image_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
runner_image_of: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 248 | my ($kv) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 248 | my ($os, $version) = map { nul($kv->{$_}) } qw( runner_image_os runner_image_version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 248 | ▶ | return defined $os || defined $version ? { os => $os, version => $version } : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $os or defined $version
MC/DC100%2/2
defined $os or defined $version
defined $os
defined $version
Truth table100%3/3
A or B
A= defined $osB= defined $version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # D2: a job on the runner itself (not in a container) names the runner image. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 223 | ▶ | sub need_runner_image { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
need_runner_image: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 223 | my ($kv, $file, $problems) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 223 | for my $k (qw( runner_image_os runner_image_version )) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 446 | ▶ | push @$problems, "$file: $k is empty on a job that runs on the runner itself" unless length $kv->{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # A part file as { file, kind, kv => { key => value, repeating key => [values] } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # nothing, with its problems pushed, when it is not a well-formed part. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 320 | ▶ | sub read_part { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_part: called CC=16 SCAR=28.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 320 | my ($path, $problems) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 320 | my $file = File::Basename::basename($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 320 | my (@pairs, $bad); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 320 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 320 | for my $line (split /\n/, DzilBinary::Publish::slurp($path)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 8266 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 8266 | ▶ | if ($line =~ /\A([a-z][a-z0-9_]*)=([\x20-\x7e]*)\z/) { push @pairs, [ $1, $2 ]; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | my ($k) = $line =~ /\A([a-z][a-z0-9_]*)=/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | push @$problems, "$file line $n: not a KEY=VALUE line of printable ASCII" . ($k ? " (key $k)" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | $bad = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 320 | ▶ | return if $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 319 | my @kind = map { $_->[1] } grep { $_->[0] eq 'kind' } @pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 319 | ▶ | if (@kind != 1 || !$KEYS{ $kind[0] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@kind != 1 or not $KEYS{$kind[0]}
MC/DC0%0/2
@kind != 1 or not $KEYS{$kind[0]}
@kind != 1
not $KEYS{$kind[0]}
Truth table33%1/3
A or not(B)
A= @kind != 1B= not $KEYS{$kind[0]}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | push @$problems, "$file: " . (!@kind ? 'no kind line' : @kind > 1 ? 'key kind repeated' : "kind '$kind[0]' is not plan, build or smoke"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 319 | my $kind = $kind[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 319 | my %known = map { $_ => 1 } @{ $KEYS{$kind} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 319 | ▶ | my $repeat = $REPEAT{$kind} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$REPEAT{$kind} || {}
MC/DC100%1/1
$REPEAT{$kind} || {}
$REPEAT{$kind}
Truth table100%2/2
A
A= $REPEAT{$kind}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 319 | my %kv = map { $_ => [] } keys %$repeat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 319 | for (@pairs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 8245 | my ($k, $v) = @$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 8245 | ▶ | if (!$known{$k}) { push @$problems, "$file: unknown key $k in a $kind part"; $bad = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 461 | elsif ($repeat->{$k}) { push @{ $kv{$k} }, $v } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | elsif (exists $kv{$k}) { push @$problems, "$file: key $k repeated"; $bad = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 7782 | else { $kv{$k} = $v } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | for my $k (grep { !exists $kv{$_} } @{ $KEYS{$kind} }) { push @$problems, "$file: no $k line"; $bad = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 319 | ▶ | return if $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 317 | return { file => $file, kind => $kind, kv => \%kv }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 29 | ▶ | sub merge { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: called CC=73 SCAR=45.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 29 | my ($meta_file, $version, $parts_dir, $assets_dir, $tarball_dir, $attempt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 29 | my @p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 29 | my $meta = DzilBinary::Publish::read_meta($meta_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 29 | my $x = $meta->{x_binaries}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 29 | my @bins = DzilBinary::Publish::binaries_of($x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 29 | my @plats = DzilBinary::Publish::platforms_of($x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 29 | my @names = DzilBinary::Publish::expected_names($x, $version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 29 | my %asset; # binary => platform => asset name, in expected_names' order | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 29 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 29 | for my $bin (@bins) { $asset{$bin}{$_} = $names[ $i++ ] for @plats } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 29 | ▶ | my %plan = map { /\A(\w+)=(.*)\z/s ? ($1 => $2) : () } DzilBinary::Plan::plan($meta_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 29 | my @legs = @{ JSON::PP->new->decode($plan{legs}) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 29 | my @cells = @{ JSON::PP->new->decode($plan{smoke}) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 29 | ▶ | opendir my $dh, $parts_dir or die "cannot read $parts_dir: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 29 | ▶ | my @files = sort grep { !/\A\./ && -f File::Spec->catfile($parts_dir, $_) } readdir $dh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
!/\A\./ && -f 'File::Spec'->catfile($parts_dir, $_)
MC/DC50%1/2
!/\A\./ && -f 'File::Spec'->catfile($parts_dir, $_)
!/\A\./
-f 'File::Spec'->catfile($parts_dir, $_)
Truth table66%2/3
not(A) && B
A= !/\A\./B= -f 'File::Spec'->catfile($parts_dir, $_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 29 | closedir $dh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 29 | my @parts = map { read_part(File::Spec->catfile($parts_dir, $_), \@p) } @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 29 | ▶ | return fail(@p) if @p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # --- the plan part --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 26 | my @plans = grep { $_->{kind} eq 'plan' } @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 26 | ▶ | return fail(@plans ? 'want exactly one plan part, found ' . join(', ', map { $_->{file} } @plans) : "no plan part in $parts_dir") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | unless @plans == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 25 | my ($pl, $pf) = @{ $plans[0] }{qw( kv file )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 25 | for my $k (qw( workflow_commit bundle_commit source_commit )) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 75 | ▶ | push @p, "$pf: $k '$pl->{$k}' is not a 40-hex commit" unless $pl->{$k} =~ $COMMIT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | push @p, "$pf: source_tag_object '$pl->{source_tag_object}' is not a 40-hex object" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 25 | ▶ | if length $pl->{source_tag_object} && $pl->{source_tag_object} !~ $COMMIT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $pl->{"source_tag_object"} and not $pl->{"source_tag_object"} =~ /$COMMIT/
MC/DC0%0/2
length $pl->{"source_tag_object"} and not $pl->{"source_tag_object"} =~ /$COMMIT/
length $pl->{"source_tag_object"}
not $pl->{"source_tag_object"} =~ /$COMMIT/
Truth table66%2/3
A and not(B)
A= length $pl->{"source_tag_object"}B= not $pl->{"source_tag_object"} =~ /$COMMIT/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 25 | ▶ | if ($pl->{bundle_source} eq 'workflow') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | push @p, "$pf: bundle_commit $pl->{bundle_commit} is not the workflow's commit $pl->{workflow_commit} (bundle_source workflow)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 24 | ▶ | unless $pl->{bundle_commit} eq $pl->{workflow_commit}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | elsif ($pl->{bundle_source} ne 'input') { push @p, "$pf: bundle_source '$pl->{bundle_source}' is not workflow or input" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 25 | ▶ | push @p, "$pf: version_slot $pl->{version_slot} is not the version $version of this run" unless $pl->{version_slot} eq $version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 25 | ▶ | if ($pl->{mode} eq 'release') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 24 | ▶ | my $v = $meta->{version} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$meta->{"version"} // ""
MC/DC0%0/1
$meta->{"version"} // ""
$meta->{"version"}
Truth table50%1/2
A
A= $meta->{"version"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 24 | ▶ | push @p, "$meta_file: version '$v' is not the version $version of this run" unless $v eq $version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | push @p, "$pf: tag '$pl->{tag}' does not end with the dist version '$v'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 24 | ▶ | unless length $v && length $pl->{tag} >= length $v && substr($pl->{tag}, -length $v) eq $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
length $v and length $pl->{"tag"} >= length $v and substr($pl->{"tag"}, -length($v)) eq $v
length $v and length $pl->{"tag"} >= length $v
MC/DC33%1/3
length $v and length $pl->{"tag"} >= length $v and substr($pl->{"tag"}, -length($v)) eq $v
length $v
length $pl->{"tag"} >= length $v
substr($pl->{"tag"}, -length($v)) eq $v
Truth table50%2/4
A and B and C
A= length $vB= length $pl->{"tag"} >= length $vC= substr($pl->{"tag"}, -length($v)) eq $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | elsif ($pl->{mode} eq 'probe') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | ▶ | push @p, "$pf: a probe has no tag, this one has tag '$pl->{tag}'" if length $pl->{tag}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | my $want = 'probe-' . substr($pl->{source_commit}, 0, 7); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | ▶ | push @p, "the version $version of this run is not $want, the probe slot of $pl->{source_commit}" unless $version eq $want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | else { push @p, "$pf: mode '$pl->{mode}' is not release or probe" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 25 | for my $part (grep { $_->{kind} ne 'plan' } @parts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | push @p, "$part->{file}: bundle_commit $part->{kv}{bundle_commit} is not the plan's $pl->{bundle_commit}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 250 | ▶ | unless $part->{kv}{bundle_commit} eq $pl->{bundle_commit}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # --- the tarball and the artifact files --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 25 | ▶ | opendir my $th, $tarball_dir or die "cannot read $tarball_dir: $!\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 25 | ▶ | my @tars = sort grep { /\.tar\.gz\z/ && -f File::Spec->catfile($tarball_dir, $_) } readdir $th; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
/\.tar\.gz\z/ && -f 'File::Spec'->catfile($tarball_dir, $_)
MC/DC50%1/2
/\.tar\.gz\z/ && -f 'File::Spec'->catfile($tarball_dir, $_)
/\.tar\.gz\z/
-f 'File::Spec'->catfile($tarball_dir, $_)
Truth table66%2/3
A && B
A= /\.tar\.gz\z/B= -f 'File::Spec'->catfile($tarball_dir, $_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 25 | closedir $th; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 25 | my $tarball; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 25 | ▶ | if (@tars == 1) { $tarball = { name => $tars[0], sha256 => sha256_file(File::Spec->catfile($tarball_dir, $tars[0])) } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | else { push @p, "want exactly one tarball (*.tar.gz) in $tarball_dir, found " . (@tars ? join(', ', @tars) : 'none') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 25 | my %hash; # asset name => sha256 of its artifact file | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 25 | for my $n (@names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 100 | my $f = File::Spec->catfile($assets_dir, $n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if (-f $f) { $hash{$n} = sha256_file($f) } else { push @p, "no artifact file $n in $assets_dir" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # --- one build part per leg of plan.pl --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 25 | my %build; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 25 | for my $part (grep { $_->{kind} eq 'build' } @parts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 49 | my $plat = $part->{kv}{platform}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if (!grep { $_->{platform} eq $plat } @legs) { push @p, "$part->{file}: platform '$plat' has no build leg" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | elsif ($build{$plat}) { push @p, "two build parts for $plat: $build{$plat}{file}, $part->{file}" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 49 | else { $build{$plat} = $part } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 25 | my @builds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 25 | for my $leg (@legs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 50 | my $plat = $leg->{platform}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 50 | ▶ | my $part = $build{$plat} or do { push @p, "no build part for $plat"; next }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 49 | my ($kv, $f) = @$part{qw( kv file )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 49 | ▶ | my $container = $leg->{container} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$leg->{"container"} // ""
MC/DC100%1/1
$leg->{"container"} // ""
$leg->{"container"}
Truth table100%2/2
A
A= $leg->{"container"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 49 | ▶ | push @p, "$f: runner '$kv->{runner}', the $plat leg runs on $leg->{runner}" unless $kv->{runner} eq $leg->{runner}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 49 | ▶ | push @p, "$f: container '$kv->{container}', the $plat leg runs in '$container'" unless $kv->{container} eq $container; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 49 | ▶ | need_runner_image($kv, $f, \@p) unless length $container; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 49 | my %want = map { $asset{$_}{$plat} => 1 } @bins; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 49 | my %line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 49 | for my $l (@{ $kv->{binary} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 97 | my ($n, $s) = $l =~ /\A(\S+) ([0-9a-f]{64})\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if (!defined $n) { push @p, "$f: binary '$l' is not '<asset> <sha256>'" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | elsif (!$want{$n}) { push @p, "$f: binary $n is not an asset of $plat" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | elsif (exists $line{$n}) { push @p, "$f: binary $n repeated" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 97 | else { $line{$n} = $s } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 49 | my @binaries; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 49 | for my $n (map { $asset{$_}{$plat} } @bins) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 98 | ▶ | if (!exists $line{$n}) { push @p, "$f: no binary line for $n"; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 97 | ▶ | push @p, "$f: $n has sha256 $line{$n}, its artifact file $hash{$n}" if defined $hash{$n} && $line{$n} ne $hash{$n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $hash{$n} and $line{$n} ne $hash{$n}
MC/DC50%1/2
defined $hash{$n} and $line{$n} ne $hash{$n}
defined $hash{$n}
$line{$n} ne $hash{$n}
Truth table66%2/3
A and B
A= defined $hash{$n}B= $line{$n} ne $hash{$n}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 97 | push @binaries, { name => $n, sha256 => $line{$n} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | push @builds, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | platform => $plat, runner => $kv->{runner}, container => nul($kv->{container}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | runner_image => runner_image_of($kv), runner_os => nul($kv->{runner_os}), runner_arch => nul($kv->{runner_arch}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | machine => machine_of($kv, 'build_'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | perl => { version => nul($kv->{perl_version}), archname => nul($kv->{perl_archname}) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | par_packer => nul($kv->{par_packer_version}), macosx_deployment_target => nul($kv->{macosx_deployment_target}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 49 | bundle_commit => $kv->{bundle_commit}, run_attempt => nul($kv->{run_attempt}), binaries => \@binaries, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # --- one smoke part per plan.pl cell and binary --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # A smoked part names its image; one that was not smoked has none, so it takes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # any free cell of its binary, platform and runner: the smoked ones go first. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 25 | my @slots = map { my $bin = $_; map { { binary => $bin, cell => $_ } } @cells } @bins; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 25 | my @smoke = grep { $_->{kind} eq 'smoke' } @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 25 | for my $part ((grep { $_->{kv}{smoked} eq 'true' } @smoke), (grep { $_->{kv}{smoked} ne 'true' } @smoke)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 201 | my ($kv, $f) = @$part{qw( kv file )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 201 | ▶ | my $what = "$kv->{binary} on $kv->{platform} ($kv->{runner}" . (length $kv->{image} ? ", $kv->{image}" : '') . ')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if ($kv->{smoked} !~ /\A(?:true|false)\z/) { push @p, "$f: smoked '$kv->{smoked}' is not true or false"; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 201 | my $smoked = $kv->{smoked} eq 'true'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if (!$smoked && length $kv->{image}) { push @p, "$f: the smoke of $what did not run, yet it names an image"; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $smoked and length $kv->{"image"}
MC/DC0%0/2
not $smoked and length $kv->{"image"}
not $smoked
length $kv->{"image"}
Truth table33%1/3
not(A) and B
A= not $smokedB= length $kv->{"image"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | my @match = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 201 | $_->{binary} eq $kv->{binary} && $_->{cell}{platform} eq $kv->{platform} && $_->{cell}{runner} eq $kv->{runner} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | && (!$smoked || ($_->{cell}{image} // '') eq $kv->{image}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 1608 | ▶ | } @slots; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition85%12/14
$_->{'binary'} eq $kv->{'binary'} && $_->{'cell'}{'platform'} eq $kv->{'platform'} && $_->{'cell'}{'runner'} eq $kv->{'runner'} && (!$smoked || ($_->{'cell'}{'image'} // '') eq $kv->{'image'})
$_->{"binary"} eq $kv->{"binary"} and $_->{"cell"}{"platform"} eq $kv->{"platform"} and $_->{"cell"}{"runner"} eq $kv->{"runner"}
$_->{"binary"} eq $kv->{"binary"} and $_->{"cell"}{"platform"} eq $kv->{"platform"}
not $smoked or ($_->{"cell"}{"image"} // "") eq $kv->{"image"}
$_->{"cell"}{"image"} // ""
MC/DC60%3/5
$_->{'binary'} eq $kv->{'binary'} && $_->{'cell'}{'platform'} eq $kv->{'platform'} && $_->{'cell'}{'runner'} eq $kv->{'runner'} && (!$smoked || ($_->{'cell'}{'image'} // '') eq $kv->{'image'})
$_->{"binary"} eq $kv->{"binary"}
$_->{"cell"}{"platform"} eq $kv->{"platform"}
$_->{"cell"}{"runner"} eq $kv->{"runner"}
not $smoked
$_->{"cell"}{"image"}
Truth table66%4/6
A and B and C && not(D) or E
A= $_->{"binary"} eq $kv->{"binary"}B= $_->{"cell"}{"platform"} eq $kv->{"platform"}C= $_->{"cell"}{"runner"} eq $kv->{"runner"}D= not $smokedE= $_->{"cell"}{"image"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 201 | my ($free) = grep { !$_->{part} } @match; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 201 | ▶ | if ($free) { $free->{part} = $part; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | ▶ | push @p, @match ? "$f: duplicate smoke part for $what (also $match[0]{part}{file})" : "$f: the smoke part for $what is no cell of plan.pl"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 25 | my @smokes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 25 | for my $s (@slots) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 200 | my $c = $s->{cell}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 200 | ▶ | if (!$s->{part}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | push @p, "no smoke part for $s->{binary} on $c->{platform} ($c->{runner}" . (defined $c->{image} ? ", $c->{image}" : '') . ')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 199 | my ($kv, $f) = @{ $s->{part} }{qw( kv file )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 199 | my $n = $asset{ $s->{binary} }{ $c->{platform} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 199 | ▶ | push @p, "$f: asset '$kv->{asset}', the cell's is $n" unless $kv->{asset} eq $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 199 | ▶ | push @p, "$f: $n has sha256 $kv->{sha256}, its artifact file $hash{$n}" if defined $hash{$n} && $kv->{sha256} ne $hash{$n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $hash{$n} and $kv->{"sha256"} ne $hash{$n}
MC/DC50%1/2
defined $hash{$n} and $kv->{"sha256"} ne $hash{$n}
defined $hash{$n}
$kv->{"sha256"} ne $hash{$n}
Truth table66%2/3
A and B
A= defined $hash{$n}B= $kv->{"sha256"} ne $hash{$n}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 199 | need_runner_image($kv, $f, \@p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 199 | my $smoked = $kv->{smoked} eq 'true'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | push @smokes, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | binary => $s->{binary}, platform => $c->{platform}, asset => $kv->{asset}, sha256 => $kv->{sha256}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | smoked => $smoked ? JSON::PP::true() : JSON::PP::false(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | runner => $kv->{runner}, runner_image => runner_image_of($kv), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | runner_os => nul($kv->{runner_os}), runner_arch => nul($kv->{runner_arch}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | host => machine_of($kv, 'host_'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | image => length $kv->{image} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | ? { ref => $kv->{image}, id => nul($kv->{image_id}), platform => nul($kv->{image_platform}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 150 | ▶ | repo_digests => [ sort @{ $kv->{image_repo_digest} } ] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | target => $smoked ? machine_of($kv, 'target_') : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 199 | ▶ | bundle_commit => $kv->{bundle_commit}, run_attempt => nul($kv->{run_attempt}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 25 | ▶ | return fail(@p) if @p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | print JSON::PP->new->canonical->pretty->ascii->encode({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | schema_version => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | mode => $pl->{mode}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | run => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | server_url => nul($pl->{server_url}), repository => nul($pl->{repository}), run_id => nul($pl->{run_id}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | attempt => nul($attempt), event => nul($pl->{event}), ref => nul($pl->{ref}), sha => nul($pl->{sha}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | caller => { workflow_ref => nul($pl->{caller_workflow_ref}), workflow_sha => nul($pl->{caller_workflow_sha}) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | workflow => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | repository => nul($pl->{workflow_repository}), path => nul($pl->{workflow_path}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ref => nul($pl->{workflow_ref}), commit => $pl->{workflow_commit}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | bundle => { ref_input => nul($pl->{bundle_ref_input}), source => $pl->{bundle_source}, commit => $pl->{bundle_commit} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | source => { commit => $pl->{source_commit}, tag => nul($pl->{tag}), tag_object => nul($pl->{source_tag_object}) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | dist => { name => nul($meta->{name}), version => nul($meta->{version}), version_slot => $pl->{version_slot}, tarball => $tarball }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 4 | assets => [ map { { name => $_, sha256 => $hash{$_} } } @names ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | builds => \@builds, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | smokes => \@smokes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 4 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 8 | ▶ | sub verify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify: called CC=22 SCAR=34.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 8 | my ($file, $sums, $tag, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 8 | my $m = eval { JSON::PP->new->decode(DzilBinary::Publish::slurp($file)) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 8 | ▶ | die "$file is not a JSON object" . ($@ ? ": $@" : "\n") unless ref $m eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 8 | ▶ | my $str = sub { my ($v) = @_; return defined $v && !ref $v ? $v : undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
Branch: 1 branch
Condition33%1/3
defined $v and not ref $v
MC/DC0%0/2
defined $v and not ref $v
defined $v
not ref $v
Truth table33%1/3
A and not(B)
A= defined $vB= not ref $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 8 | ▶ | my $sub = sub { my ($k, $f) = @_; return ref $m->{$k} eq 'HASH' ? $str->($m->{$k}{$f}) : undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 8 | my @p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | my %got = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | schema_version => [ $str->($m->{schema_version}), 1 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 8 | mode => [ $str->($m->{mode}), 'release' ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 'source.tag' => [ $sub->(source => 'tag'), $tag ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 'dist.version_slot' => [ $sub->(dist => 'version_slot'), $version ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 8 | for my $k (sort keys %got) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 32 | my ($have, $want) = @{ $got{$k} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 32 | ▶ | push @p, "$file: $k is " . ($have // 'null') . ", want $want" unless defined $have && $have eq $want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
defined $have and $have eq $want
$have // "null"
MC/DC50%1/2
defined $have and $have eq $want
defined $have
$have eq $want
MC/DC0%0/1
$have // "null"
$have
Truth table66%2/3
A and B
A= defined $haveB= $have eq $want
Truth table50%1/2
A
A= $have
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 8 | my %want; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 8 | ▶ | for my $e (ref $m->{assets} eq 'ARRAY' ? @{ $m->{assets} } : ()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 32 | ▶ | my ($n, $s) = ref $e eq 'HASH' ? map { $str->($e->{$_}) } qw( name sha256 ) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if (!defined $n || !defined $s) { push @p, "$file: an asset without name or sha256" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $n && defined $s
MC/DC0%0/2
defined $n && defined $s
defined $n
defined $s
Truth table33%1/3
A && B
A= defined $nB= defined $s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | elsif (exists $want{$n}) { push @p, "$file: asset $n listed twice" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 32 | else { $want{$n} = $s } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 8 | ▶ | push @p, "$file: no assets" unless %want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 8 | my %have; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 8 | my $n = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 8 | for my $line (split /\n/, DzilBinary::Publish::slurp($sums)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 32 | $n++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 32 | my ($s, $name) = $line =~ /\A([0-9a-f]{64}) (\S+)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if (!defined $s) { push @p, "$sums line $n: not '<sha256> <name>'" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | elsif (exists $have{$name}) { push @p, "$sums: $name listed twice" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 32 | else { $have{$name} = $s } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 8 | for my $name (sort keys %want) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 32 | ▶ | if (!exists $have{$name}) { push @p, "SHA256SUMS has no line for $name of the manifest" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | elsif ($have{$name} ne $want{$name}) { push @p, "$name: SHA256SUMS has $have{$name}, the manifest $want{$name}" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 8 | push @p, "SHA256SUMS lists $_, the manifest does not" for grep { !exists $want{$_} } sort keys %have; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 8 | ▶ | return @p ? fail(@p) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 5 | ▶ | sub artifact { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
artifact: called CC=6 SCAR=19.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 5 | my ($meta_file, $version) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 5 | my $name = DzilBinary::Publish::read_meta($meta_file)->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 5 | for my $v ($name, $version) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 7 | ▶ | die "refusing '" . ($v // '') . "': only letters, digits, '.', '_', '-', '+' are allowed\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%4/8
defined $v and not ref $v and $v =~ /\A[A-Za-z0-9._+-]+\z/
defined $v and not ref $v
$v // ""
MC/DC33%1/3
defined $v and not ref $v and $v =~ /\A[A-Za-z0-9._+-]+\z/
defined $v
not ref $v
$v =~ /\A[A-Za-z0-9._+-]+\z/
MC/DC0%0/1
$v // ""
$v
Truth table50%2/4
A and not(B) and C
A= defined $vB= not ref $vC= $v =~ /\A[A-Za-z0-9._+-]+\z/
Truth table50%1/2
A
A= $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | unless defined $v && !ref $v && $v =~ /\A[A-Za-z0-9._+-]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | return "$name-$version.provenance"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 43 | ▶ | sub main { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
main: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 43 | my ($cmd, @a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 43 | ▶ | $cmd //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cmd //= ""
MC/DC0%0/1
$cmd //= ""
$cmd
Truth table50%1/2
A
A= $cmd
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 43 | my $rc = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 43 | ▶ | if ($cmd eq 'merge' && @a == 6) { merge(@a) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$cmd eq "merge" and @a == 6
MC/DC50%1/2
$cmd eq "merge" and @a == 6
$cmd eq "merge"
@a == 6
Truth table66%2/3
A and B
A= $cmd eq "merge"B= @a == 6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 8 | ▶ | elsif ($cmd eq 'verify' && @a == 4) { verify(@a) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$cmd eq "verify" and @a == 4
MC/DC50%1/2
$cmd eq "verify" and @a == 4
$cmd eq "verify"
@a == 4
Truth table66%2/3
A and B
A= $cmd eq "verify"B= @a == 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 5 | ▶ | elsif ($cmd eq 'artifact' && @a == 2) { my $n = artifact(@a); print "$n\n"; 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$cmd eq "artifact" and @a == 2
MC/DC50%1/2
$cmd eq "artifact" and @a == 2
$cmd eq "artifact"
@a == 2
Truth table66%2/3
A and B
A= $cmd eq "artifact"B= @a == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | else { die "usage: provenance.pl merge|verify|artifact ...\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 43 | ▶ | if (!defined $rc) { print STDERR $@; return 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 38 | return $rc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 43 | ▶ | exit main(@ARGV) unless caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||