| 1 | package Test::Smoke::Syncer::Snapshot; | ||||||||||||||||||||||||||||
| 2 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 12 | our $VERSION = '0.029'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use base 'Test::Smoke::Syncer::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 Test::Smoke::Syncer::Snapshot | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | This handles syncing from an HTTP snapshot (Porting/make_snapshot.pl) | ||||||||||||||||||||||||||||
| 12 | It should only be visible from the "parent-package" so no direct | ||||||||||||||||||||||||||||
| 13 | user-calls on this. | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =cut | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 12 | ▶ | use Cwd; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 12 | ▶ | use File::Path; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 12 | ▶ | use Test::Smoke::Util qw( whereis clean_filename ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =head2 Test::Smoke::Syncer::Snapshot->new( %args ) | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | This crates the new object. Keys for C<%args>: | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | * ddir: destination directory ( ./perl-current ) | ||||||||||||||||||||||||||||
| 26 | * snapurl: the server to get the download from | ||||||||||||||||||||||||||||
| 27 | * snaptar: howto untar ( Archive::Tar or 'gzip -d -c %s | tar x -' ) | ||||||||||||||||||||||||||||
| 28 | * v: verbose | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =head2 $syncer->sync( ) | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | Fetch the file. Remove the current source-tree | ||||||||||||||||||||||||||||
| 35 | and extract the tarball or zip. | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =cut | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 2 | ▶ | sub sync { | ||||||||||||||||||||||||||
|
Subroutine
sync: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 2 | $self->pre_sync; | |||||||||||||||||||||||||||
| 43 | # we need to have {ddir} before we can save the snapshot | ||||||||||||||||||||||||||||
| 44 | 2 | ▶ | -d $self->{ddir} or mkpath( $self->{ddir} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 2 | ▶ | $self->{archive} = $self->_fetch_archive or return undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 2 | $self->_clear_source_tree; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 2 | $self->_extract_archive; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 2 | my $plevel = $self->check_dot_git_patch; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 2 | ▶ | if (not defined $plevel) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | $self->check_dot_patch; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 2 | $self->post_sync; | |||||||||||||||||||||||||||
| 60 | 2 | return $plevel; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head2 $syncer->_fetch_archive( ) | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | C<_fetch_archive()> downloads the archive | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 2 | ▶ | sub _fetch_archive { | ||||||||||||||||||||||||||
|
Subroutine
_fetch_archive: called CC=8 SCAR=27.7
| |||||||||||||||||||||||||||||
| 70 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 2 | require LWP::Simple; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 2 | ▶ | unless ( $self->{snapurl} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | require Carp; | |||||||||||||||||||||||||||
| 76 | 0 | Carp::carp( "No URL specified for $self->{snapurl}" ); | |||||||||||||||||||||||||||
| 77 | 0 | return undef; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 2 | my @pieces = split "/", $self->{snapurl}; | |||||||||||||||||||||||||||
| 81 | 2 | my $snapfile = pop @pieces; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 2 | my $local_archive = File::Spec->catfile( $self->{ddir}, File::Spec->updir, $snapfile ); | |||||||||||||||||||||||||||
| 85 | 2 | $local_archive = File::Spec->canonpath( $local_archive ); | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 2 | my $remote_archive = "$self->{snapurl}"; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 2 | ▶ | $self->{v} and print "LWP::Simple::mirror($remote_archive)"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 2 | my $result = LWP::Simple::mirror( $remote_archive, $local_archive ); | |||||||||||||||||||||||||||
| 91 | 2 | ▶ | if ( LWP::Simple::is_success( $result ) ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 92 | 2 | ▶ | $self->{v} and print " OK\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 2 | return $local_archive; | |||||||||||||||||||||||||||
| 94 | } elsif ( LWP::Simple::is_error( $result ) ) { | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | $self->{v} and print " not OK\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 0 | return undef; | |||||||||||||||||||||||||||
| 97 | } else { | ||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $self->{v} and print " skipped\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 0 | return $local_archive; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head2 $syncer->_extract_archive( ) | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | C<_extract_archive()> checks the B<tar> attribute to find out how to | ||||||||||||||||||||||||||||
| 107 | extract the archive. This could be an external command or the | ||||||||||||||||||||||||||||
| 108 | B<Archive::Tar>/B<Comperss::Zlib> modules. | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =cut | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 2 | ▶ | sub _extract_archive { | ||||||||||||||||||||||||||
|
Subroutine
_extract_archive: called CC=9 SCAR=26.5
| |||||||||||||||||||||||||||||
| 113 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 2 | ▶ | unless ( $self->{archive} && -f $self->{archive} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"archive"} and -f $self->{"archive"}
MC/DC0%0/2
$self->{"archive"} and -f $self->{"archive"}
$self->{"archive"}
-f $self->{"archive"}
Truth table33%1/3
A and B
A= $self->{"archive"}B= -f $self->{"archive"}
| |||||||||||||||||||||||||||||
| 116 | 0 | require Carp; | |||||||||||||||||||||||||||
| 117 | 0 | Carp::carp( "No archive to be extracted!" ); | |||||||||||||||||||||||||||
| 118 | 0 | return undef; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 2 | my $cwd = cwd(); | |||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | # Files in the archive are relative to the 'perl/' directory, | ||||||||||||||||||||||||||||
| 124 | # they may need to be moved and that is not easy when you've | ||||||||||||||||||||||||||||
| 125 | # extracted them in the target directory! so we go updir() | ||||||||||||||||||||||||||||
| 126 | 2 | ▶ | my $ddir = $^O eq 'VMS' ? $self->{vms_ddir} : $self->{ddir}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 2 | my $extract_base = File::Spec->catdir( $ddir, File::Spec->updir ); | |||||||||||||||||||||||||||
| 128 | 2 | ▶ | chdir $extract_base or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 0 | require Carp; | |||||||||||||||||||||||||||
| 130 | 0 | Carp::croak( "Can't chdir '$extract_base': $!" ); | |||||||||||||||||||||||||||
| 131 | }; | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 2 | my $archive_base; | |||||||||||||||||||||||||||
| 134 | EXTRACT: { | ||||||||||||||||||||||||||||
| 135 | 2 | ▶ | local $_ = $self->{snaptar} || 'Archive::Tar'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'snaptar'} || 'Archive::Tar'
MC/DC0%0/1
$self->{'snaptar'} || 'Archive::Tar'
$self->{'snaptar'}
Truth table50%1/2
A
A= $self->{'snaptar'}
| |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 2 | ▶ | /^Archive::Tar$/ && do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 2 | $archive_base = $self->_extract_with_Archive_Tar; | |||||||||||||||||||||||||||
| 139 | 2 | last EXTRACT; | |||||||||||||||||||||||||||
| 140 | }; | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | # assume a commandline template for $self->{tar} | ||||||||||||||||||||||||||||
| 143 | 0 | $archive_base = $self->_extract_with_external; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 2 | $self->_relocate_tree( $archive_base ); | |||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 2 | ▶ | chdir $cwd or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 0 | require Carp; | |||||||||||||||||||||||||||
| 150 | 0 | Carp::croak( "Can't chdir($extract_base) back: $!" ); | |||||||||||||||||||||||||||
| 151 | }; | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 2 | ▶ | 1 while unlink $self->{archive}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =head2 $syncer->_extract_with_Archive_Tar( ) | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | C<_extract_with_Archive_Tar()> uses the B<Archive::Tar> and | ||||||||||||||||||||||||||||
| 159 | B<Compress::Zlib> modules to extract the archive. | ||||||||||||||||||||||||||||
| 160 | (This tested verry slow on my Linux box!) | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =cut | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 2 | ▶ | sub _extract_with_Archive_Tar { | ||||||||||||||||||||||||||
|
Subroutine
_extract_with_Archive_Tar: called CC=6 SCAR=20.8
| |||||||||||||||||||||||||||||
| 165 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 2 | require Archive::Tar; | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 2 | ▶ | my $archive = Archive::Tar->new() or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 0 | require Carp; | |||||||||||||||||||||||||||
| 171 | 0 | Carp::carp( "Can't Archive::Tar->new: " . $Archive::Tar::error ); | |||||||||||||||||||||||||||
| 172 | 0 | return undef; | |||||||||||||||||||||||||||
| 173 | }; | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 2 | ▶ | $self->{v} and printf "Extracting '$self->{archive}' (%s) ", cwd(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | 2 | $archive->read( $self->{archive}, 1 ); | |||||||||||||||||||||||||||
| 177 | 2 | ▶ | $Archive::Tar::error and do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 0 | require Carp; | |||||||||||||||||||||||||||
| 179 | 0 | Carp::carp("Error reading '$self->{archive}': ".$Archive::Tar::error); | |||||||||||||||||||||||||||
| 180 | 0 | return undef; | |||||||||||||||||||||||||||
| 181 | }; | ||||||||||||||||||||||||||||
| 182 | 2 | my @files = $archive->list_files; | |||||||||||||||||||||||||||
| 183 | 2 | $archive->extract( @files ); | |||||||||||||||||||||||||||
| 184 | 2 | ▶ | $self->{v} and printf "%d items OK.\n", scalar @files; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 2 | ( my $prefix = $files[0] ) =~ s|^([^/]+).+$|$1|; | |||||||||||||||||||||||||||
| 187 | 2 | my $base_dir = File::Spec->canonpath(File::Spec->catdir( cwd(), $prefix )); | |||||||||||||||||||||||||||
| 188 | 2 | ▶ | $self->{v} and print "Archive prefix: '$base_dir'\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 2 | return $base_dir; | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | =head2 $syncer->_extract_with_external( ) | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | C<_extract_with_external()> uses C<< $self->{snaptar} >> as a sprintf() | ||||||||||||||||||||||||||||
| 195 | template to build a command. Yes that might be dangerous! | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | =cut | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub _extract_with_external { | ||||||||||||||||||||||||||
|
Subroutine
_extract_with_external: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||
| 200 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | my @dirs_pre = __get_directory_names(); | |||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ( $^O ne 'VMS' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 0 | my $command = sprintf $self->{snaptar}, $self->{archive}; | |||||||||||||||||||||||||||
| 206 | 0 | ▶ | $command .= " $self->{archive}" if $command eq $self->{snaptar}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | $self->{v} and print "$command "; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ( system $command ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 0 | my $error = $? >> 8; | |||||||||||||||||||||||||||
| 211 | 0 | require Carp; | |||||||||||||||||||||||||||
| 212 | 0 | Carp::carp( "Error in command: $error" ); | |||||||||||||||||||||||||||
| 213 | 0 | return undef; | |||||||||||||||||||||||||||
| 214 | }; | ||||||||||||||||||||||||||||
| 215 | 0 | ▶ | $self->{v} and print "OK\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | } else { | ||||||||||||||||||||||||||||
| 217 | 0 | __vms_untargz( $self->{snaptar}, $self->{archive}, $self->{v} ); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | # Yes another process can also create directories here! | ||||||||||||||||||||||||||||
| 221 | # Be careful. | ||||||||||||||||||||||||||||
| 222 | 0 | my %dirs_post = map { ($_ => 1) } __get_directory_names(); | |||||||||||||||||||||||||||
| 223 | exists $dirs_post{ $_ } and delete $dirs_post{ $_ } | ||||||||||||||||||||||||||||
| 224 | 0 | ▶ | foreach @dirs_pre; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | # I'll pick the first one that has 'perl' in it | ||||||||||||||||||||||||||||
| 226 | 0 | ▶ | my( $prefix ) = grep /\bperl/ || /perl\b/ => keys %dirs_post; | ||||||||||||||||||||||||||
|
Condition0%0/3
/\bperl/ || /perl\b/
MC/DC0%0/2
/\bperl/ || /perl\b/
/\bperl/
/perl\b/
Truth table0%0/3
A || B
A= /\bperl/B= /perl\b/
| |||||||||||||||||||||||||||||
| 227 | 0 | ▶ | my $ddir = $^O eq 'VMS' ? $self->{vms_ddir} : $self->{ddir}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 0 | ▶ | $prefix ||= File::Spec->abs2rel( $ddir, cwd() ); | ||||||||||||||||||||||||||
|
Condition0%0/3
$prefix ||= "File::Spec"->abs2rel($ddir, cwd())
MC/DC0%0/2
$prefix ||= "File::Spec"->abs2rel($ddir, cwd())
$prefix
"File::Spec"->abs2rel($ddir, cwd())
Truth table0%0/3
A ||= B
A= $prefixB= "File::Spec"->abs2rel($ddir, cwd())
| |||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 0 | my $base_dir = File::Spec->canonpath(File::Spec->catdir( cwd(), $prefix )); | |||||||||||||||||||||||||||
| 231 | 0 | ▶ | $self->{v} and print "Archive prefix: '$base_dir'\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 0 | return $base_dir; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | =head2 __get_directory_names( [$dir] ) | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | [This is B<not> a method] | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | C<__get_directory_names()> retruns all directory names from | ||||||||||||||||||||||||||||
| 240 | C<< $dir || cwd() >>. It does not look at symlinks (there should | ||||||||||||||||||||||||||||
| 241 | not be any in the perl source-tree). | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | =cut | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub __get_directory_names { | ||||||||||||||||||||||||||
|
Subroutine
__get_directory_names: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 246 | 0 | ▶ | my $dir = shift || cwd(); | ||||||||||||||||||||||||||
|
Condition0%0/3
shift() || cwd()
MC/DC0%0/2
shift() || cwd()
shift()
cwd()
Truth table0%0/3
A || B
A= shift()B= cwd()
| |||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | local *DIR; | |||||||||||||||||||||||||||
| 249 | 0 | ▶ | opendir DIR, $dir or return (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 0 | my @dirs = grep -d File::Spec->catfile( $dir, $_ ) => readdir DIR; | |||||||||||||||||||||||||||
| 251 | 0 | closedir DIR; | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 0 | return @dirs; | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | =head2 __vms_untargz( $untargz, $tgzfile, $verbose ) | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | Gunzip and extract the archive in C<$tgzfile> using a small DCL script | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | =cut | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 0 | ▶ | sub __vms_untargz { | ||||||||||||||||||||||||||
|
Subroutine
__vms_untargz: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||
| 265 | 0 | my( $cmd, $file, $verbose ) = @_; | |||||||||||||||||||||||||||
| 266 | 0 | my( $gzip_cmd, $tar_cmd ) = split /\s*\|\s*/, $cmd; | |||||||||||||||||||||||||||
| 267 | 0 | ▶ | my $gzip = $gzip_cmd =~ /^((?:MCR )?\S+)/ ? $1 : 'GZIP'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 268 | 0 | ▶ | my $tar = $tar_cmd =~ /^((?:MCR )?\S+)/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
whereis("vmstar") or whereis("tar")
MC/DC0%0/2
whereis("vmstar") or whereis("tar")
whereis("vmstar")
whereis("tar")
Truth table0%0/3
A or B
A= whereis("vmstar")B= whereis("tar")
| |||||||||||||||||||||||||||||
| 269 | ? $1 : (whereis( 'vmstar' ) || whereis( 'tar' ) ); | ||||||||||||||||||||||||||||
| 270 | 0 | ▶ | my $tar_sw = $verbose ? '-xvf' : '-xf'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 0 | ▶ | $verbose and print "Writing 'TS-UNTGZ.COM'"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 273 | 0 | local *TMPCOM; | |||||||||||||||||||||||||||
| 274 | 0 | ▶ | open TMPCOM, "> TS-UNTGZ.COM" or return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | 0 | ▶ | print TMPCOM <<EO_UNTGZ; close TMPCOM or return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | \$! TS-UNTGZ.COM - Generated by Test::Smoke::Syncer | ||||||||||||||||||||||||||||
| 277 | \$ define/user sys\$output TS-UNTGZ.TAR | ||||||||||||||||||||||||||||
| 278 | \$ $gzip "-cd" $file | ||||||||||||||||||||||||||||
| 279 | \$ $tar $tar_sw TS-UNTGZ.TAR | ||||||||||||||||||||||||||||
| 280 | \$ delete TS-UNTGZ.TAR;* | ||||||||||||||||||||||||||||
| 281 | EO_UNTGZ | ||||||||||||||||||||||||||||
| 282 | 0 | ▶ | $verbose and print " OK\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 0 | my $ret = system "\@TS-UNTGZ.COM"; | |||||||||||||||||||||||||||
| 285 | 0 | ▶ | 1 while unlink "TS-UNTGZ.COM"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 0 | return ! $ret; | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | 12 | 1; | |||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | (c) 2002-2013, All rights reserved. | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | * Abe Timmerman <abeltje@cpan.org> | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 299 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | See: | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | * <http://www.perl.com/perl/misc/Artistic.html>, | ||||||||||||||||||||||||||||
| 304 | * <http://www.gnu.org/copyleft/gpl.html> | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 307 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 308 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | =cut | ||||||||||||||||||||||||||||