| 1 | 1 | ▶ | use v5.40; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | 1 | class Alien::Xrepo::Build::Dist v1.0.10 { | |||||||||||||||||||||||||||
| 6 | 1 | ▶ | use File::Find; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | 1 | field $base_dir : reader : param //= '.'; | |||||||||||||||||||||||||||
| 10 | 1 | field $script : reader : param //= 'Build.PL'; # XXX - I could do this with caller() | |||||||||||||||||||||||||||
| 11 | 1 | field $module_name : reader : param; # Required | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # lib/Alien/Foo.pm for Alien::Foo | ||||||||||||||||||||||||||||
| 14 | 5 | ▶ | method module_rel () { | ||||||||||||||||||||||||||
|
Subroutine
module_rel: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 5 | ( my $rel = $module_name . '.pm' ) =~ s{::}{/}g; | |||||||||||||||||||||||||||
| 16 | 5 | $rel; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | 4 | ▶ | method module_path () { path($base_dir)->child( 'lib', $self->module_rel )->stringify } | ||||||||||||||||||||||||||
|
Subroutine
module_path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | method dist_name () { $module_name =~ s{::}{-}gr } | ||||||||||||||||||||||||||
|
Subroutine
dist_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # The conventional place the hermetic snapshot lands: blib/lib/auto/share/dist/<Dist>/xrepo-snapshot.json | ||||||||||||||||||||||||||||
| 22 | 1 | ▶ | method snapshot_path () { | ||||||||||||||||||||||||||
|
Subroutine
snapshot_path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 1 | path($base_dir)->child( 'blib', 'lib', 'auto', 'share', 'dist', $self->dist_name, 'xrepo-snapshot.json' )->stringify; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # The dist's single declaration: the Alien::<Tail> subclass's recipe() (a hashref, an Alien::Xrepo::Build::Recipe | ||||||||||||||||||||||||||||
| 27 | # object, or a path). The engine normalizes whatever comes back. Requires lib/<class>.pm by its absolute path so | ||||||||||||||||||||||||||||
| 28 | # it wins over any pre-installed copy. | ||||||||||||||||||||||||||||
| 29 | 0 | ▶ | method recipe () { | ||||||||||||||||||||||||||
|
Subroutine
recipe: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 0 | require( path( $self->module_path )->absolute->stringify ); | |||||||||||||||||||||||||||
| 31 | 0 | return $module_name->new->recipe; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # Inputs whose freshness determines whether the snapshot needs regenerating: the dist's own recipe inputs (the | ||||||||||||||||||||||||||||
| 35 | # build script and lib/<class>.pm), whatever engine modules from the given list are loaded into THIS process (%INC, | ||||||||||||||||||||||||||||
| 36 | # so a parent install bump re-runs the examples), and any local recipes/ tree is folded in by snapshot_stale, not | ||||||||||||||||||||||||||||
| 37 | # here. | ||||||||||||||||||||||||||||
| 38 | 2 | ▶ | method inputs (@engine_mods) { | ||||||||||||||||||||||||||
|
Subroutine
inputs: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 2 | my @inputs = ( path($base_dir)->child($script)->stringify, $self->module_path ); | |||||||||||||||||||||||||||
| 40 | 2 | for my $mod (@engine_mods) { | |||||||||||||||||||||||||||
| 41 | 0 | ▶ | push @inputs, $INC{$mod} if defined $INC{$mod}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 2 | return @inputs; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # True when the snapshot is missing or older than any input (mirroring Module::Build's copy_if_modified semantics) | ||||||||||||||||||||||||||||
| 47 | # or any file under a local recipes/ tree. | ||||||||||||||||||||||||||||
| 48 | 3 | ▶ | method snapshot_stale ( $snapshot, @engine_mods ) { | ||||||||||||||||||||||||||
|
Subroutine
snapshot_stale: called CC=8 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 3 | ▶ | return 1 unless -e $snapshot; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 2 | ▶ | return 1 if !-f $snapshot || -z $snapshot; # a directory or empty file can't be a valid snapshot | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not -f $snapshot or -z $snapshot
MC/DC0%0/2
not -f $snapshot or -z $snapshot
not -f $snapshot
-z $snapshot
Truth table33%1/3
not(A) or B
A= not -f $snapshotB= -z $snapshot
| |||||||||||||||||||||||||||||
| 51 | 2 | my $mtime = _mtime($snapshot); | |||||||||||||||||||||||||||
| 52 | 2 | for my $file ( $self->inputs(@engine_mods) ) { | |||||||||||||||||||||||||||
| 53 | 4 | ▶ | next unless -e $file; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 4 | ▶ | return 1 if _mtime($file) > $mtime; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | 1 | my $base = path($base_dir); | |||||||||||||||||||||||||||
| 57 | 1 | my $stale = 0; | |||||||||||||||||||||||||||
| 58 | 1 | ▶ | if ( -d $base->child('recipes') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | find( | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $stale = 1 if -f $_ && _mtime( path($File::Find::name) ) > $mtime; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $_ and _mtime(path($File::Find::name)) > $mtime
MC/DC0%0/2
-f $_ and _mtime(path($File::Find::name)) > $mtime
-f $_
_mtime(path($File::Find::name)) > $mtime
Truth table0%0/3
A and B
A= -f $_B= _mtime(path($File::Find::name)) > $mtime
| |||||||||||||||||||||||||||||
| 62 | }, | ||||||||||||||||||||||||||||
| 63 | 0 | $base->child('recipes')->stringify | |||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 1 | $stale; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 6 | ▶ | sub _mtime ($path) { | ||||||||||||||||||||||||||
|
Subroutine
_mtime: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 70 | 6 | my @st = stat $path; | |||||||||||||||||||||||||||
| 71 | 6 | ▶ | return $st[9] // -1; | ||||||||||||||||||||||||||
|
Condition50%1/2
$st[9] // -1
MC/DC0%0/1
$st[9] // -1
$st[9]
Truth table50%1/2
A
A= $st[9]
| |||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | }; | ||||||||||||||||||||||||||||
| 74 | # | ||||||||||||||||||||||||||||
| 75 | 1 | 1; | |||||||||||||||||||||||||||
| 76 | __END__ | ||||||||||||||||||||||||||||