| 1 | package Test::Smoke::Syncer::Base; | ||||||||||||||||||||||||||||
| 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 | 12 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 12 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 12 | ▶ | use Cwd qw/cwd abs_path/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 12 | ▶ | use Test::Smoke::Util qw/whereis/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 12 | ▶ | use Test::Smoke::LogMixin; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | Test;:Smoke::Syncer::Base - Base class for all the syncers. | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head2 Test::Smoke::Syncer::Baase->new(%arguments) | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | Return a new instance. | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =cut | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 18 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | 18 | my $class = shift; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 18 | return bless {@_}, $class; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head2 $syncer->verbose | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | Get/Set verbosity. | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =cut | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 72 | ▶ | sub verbose { | ||||||||||||||||||||||||||
|
Subroutine
verbose: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 72 | my $self = shift; | |||||||||||||||||||||||||||
| 38 | 72 | ▶ | $self->{v} = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 72 | return $self->{v}; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =head2 $syncer->sync() | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | Abstract method. | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub sync { | ||||||||||||||||||||||||||
|
Subroutine
sync: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||
| 51 | 0 | Carp::croak("Should have been implemented by '$class'"); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head2 $syncer->_clear_souce_tree( [$tree_dir] ) | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | [ Method | private-ish ] | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | C<_clear_source_tree()> removes B<all> files in the source-tree | ||||||||||||||||||||||||||||
| 59 | using B<File::Path::rmtree()>. (See L<File::Path> for caveats.) | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | If C<$tree_dir> is not specified, C<< $self->{ddir} >> is used. | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =cut | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 2 | ▶ | sub _clear_source_tree { | ||||||||||||||||||||||||||
|
Subroutine
_clear_source_tree: called CC=3 SCAR=11.6
| |||||||||||||||||||||||||||||
| 66 | 2 | my( $self, $tree_dir ) = @_; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 2 | ▶ | $tree_dir ||= $self->{ddir}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$tree_dir ||= $self->{"ddir"}
MC/DC0%0/2
$tree_dir ||= $self->{"ddir"}
$tree_dir
$self->{"ddir"}
Truth table33%1/3
A ||= B
A= $tree_dirB= $self->{"ddir"}
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 2 | $self->log_info("Clear source-tree from '$tree_dir' "); | |||||||||||||||||||||||||||
| 71 | 2 | my $cnt = File::Path::rmtree( $tree_dir, $self->{v} > 1 ); | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 2 | ▶ | File::Path::mkpath( $tree_dir, $self->{v} > 1 ) unless -d $tree_dir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 2 | $self->log_info("clear-source-tree: $cnt items OK"); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head2 $syncer->_relocate_tree( $source_dir ) | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | [ Method | Private-ish ] | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | C<_relocate_tree()> uses B<File::Copy::move()> to move the source-tree | ||||||||||||||||||||||||||||
| 83 | from C<< $source_dir >> to its destination (C<< $self->{ddir} >>). | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 2 | ▶ | sub _relocate_tree { | ||||||||||||||||||||||||||
|
Subroutine
_relocate_tree: called CC=10 SCAR=36.3
| |||||||||||||||||||||||||||||
| 88 | 2 | my( $self, $source_dir ) = @_; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 2 | require File::Copy; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 2 | ▶ | $self->{v} and print "relocate source-tree "; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | # try to move it at once (sort of a rename) | ||||||||||||||||||||||||||||
| 95 | 2 | ▶ | my $ddir = $^O eq 'VMS' ? $self->{vms_ddir} : $self->{ddir}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | my $ok = $source_dir eq $ddir | ||||||||||||||||||||||||||||
| 97 | 2 | ▶ | ? 1 : File::Copy::move( $source_dir, $self->{ddir} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | # Failing that: Copy-By-File :-( | ||||||||||||||||||||||||||||
| 100 | 2 | ▶ | if ( ! $ok && -d $source_dir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $ok and -d $source_dir
MC/DC0%0/2
not $ok and -d $source_dir
not $ok
-d $source_dir
Truth table33%1/3
not(A) and B
A= not $okB= -d $source_dir
| |||||||||||||||||||||||||||||
| 101 | 0 | my $cwd = cwd(); | |||||||||||||||||||||||||||
| 102 | 0 | ▶ | chdir $source_dir or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | print "Cannot chdir($source_dir): $!\n"; | |||||||||||||||||||||||||||
| 104 | 0 | return 0; | |||||||||||||||||||||||||||
| 105 | }; | ||||||||||||||||||||||||||||
| 106 | 0 | require File::Find; | |||||||||||||||||||||||||||
| 107 | 0 | ▶ | File::Find::finddepth( sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | my $dest = File::Spec->canonpath( $File::Find::name ); | |||||||||||||||||||||||||||
| 110 | 0 | $dest =~ s/^\Q$source_dir//; | |||||||||||||||||||||||||||
| 111 | 0 | $dest = File::Spec->catfile( $self->{ddir}, $dest ); | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | $self->{v} > 1 and print "move $_ $dest\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | File::Copy::move( $_, $dest ); | |||||||||||||||||||||||||||
| 115 | 0 | }, "./" ); | |||||||||||||||||||||||||||
| 116 | 0 | ▶ | chdir $cwd or print "Cannot chdir($cwd) back: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | File::Path::rmtree( $source_dir, $self->{v} > 1 ); | |||||||||||||||||||||||||||
| 118 | 0 | $ok = ! -d $source_dir; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 2 | ▶ | die "Can't move '$source_dir' to $self->{ddir}' ($!)" unless $ok; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 2 | ▶ | $self->{v} and print "OK\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =head2 $syncer->check_dot_git_patch( ) | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | [ Method | Public ] | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | C<check_dot_git_patch()> checks if there is a '.git_patch' file in the source-tree. | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | It returns the patchlevel found or C<undef>. | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =cut | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 2 | ▶ | sub check_dot_git_patch { | ||||||||||||||||||||||||||
|
Subroutine
check_dot_git_patch: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 135 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 2 | my $dot_git_patch = File::Spec->catfile( $self->{ddir}, '.git_patch' ); | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 2 | local *DOTGITPATCH; | |||||||||||||||||||||||||||
| 140 | 2 | my $patch_level = '?????'; | |||||||||||||||||||||||||||
| 141 | 2 | ▶ | if ( open DOTGITPATCH, "< $dot_git_patch" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 2 | chomp( $patch_level = <DOTGITPATCH> ); | |||||||||||||||||||||||||||
| 143 | 2 | close DOTGITPATCH; | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 2 | ▶ | if ( $patch_level ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 2 | ▶ | return undef if ( $patch_level =~ /^\$Format/ ); # Not expanded | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 2 | my @dot_git_patch = split '\|', $patch_level; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | # As we do not use time information, we can just pick the first and | ||||||||||||||||||||||||||||
| 152 | # the last two elements | ||||||||||||||||||||||||||||
| 153 | 2 | my ($sha, $describe, $names) = @dot_git_patch[0, -2, -1]; | |||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 2 | return $sha; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | 0 | return undef; | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | =head2 $syncer->check_dot_patch( ) | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | [ Method | Public ] | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | C<check_dot_patch()> checks if there is a '.patch' file in the source-tree. | ||||||||||||||||||||||||||||
| 166 | It will try to create one if it is not there (this is the case for snapshots). | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | It returns the patchlevel found or C<undef>. | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | =cut | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 13 | ▶ | sub check_dot_patch { | ||||||||||||||||||||||||||
|
Subroutine
check_dot_patch: called CC=16 SCAR=48.2
Pod
documented
| |||||||||||||||||||||||||||||
| 173 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 13 | my $dot_patch = File::Spec->catfile( $self->{ddir}, '.patch' ); | |||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 13 | local *DOTPATCH; | |||||||||||||||||||||||||||
| 178 | 13 | my $patch_level = '?????'; | |||||||||||||||||||||||||||
| 179 | 13 | ▶ | if ( open DOTPATCH, "< $dot_patch" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 13 | chomp( $patch_level = <DOTPATCH> ); | |||||||||||||||||||||||||||
| 181 | 13 | close DOTPATCH; | |||||||||||||||||||||||||||
| 182 | # From rsync: | ||||||||||||||||||||||||||||
| 183 | # blead 2019-11-06.00:32:06 +0100 cc8ba724ccabff255f384ab68d6f6806ac2eae7c v5.31.5-174-gcc8ba72 | ||||||||||||||||||||||||||||
| 184 | # from make_dot_patch.pl: | ||||||||||||||||||||||||||||
| 185 | # blead 2019-11-05.23:32:06 cc8ba724ccabff255f384ab68d6f6806ac2eae7c v5.31.5-174-gcc8ba724cc | ||||||||||||||||||||||||||||
| 186 | 13 | ▶ | if ( $patch_level ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 13 | my @dot_patch = split ' ', $patch_level; | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | # As we do not use time information, we can just pick the first and | ||||||||||||||||||||||||||||
| 190 | # the last two elements | ||||||||||||||||||||||||||||
| 191 | 13 | my ($branch, $sha, $describe) = @dot_patch[0, -2, -1]; | |||||||||||||||||||||||||||
| 192 | # $sha -> sysinfo.git_id | ||||||||||||||||||||||||||||
| 193 | # $describe -> sysinfo.git_describe | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 13 | ▶ | $self->{patchlevel} = $sha || $branch; | ||||||||||||||||||||||||||
|
Condition66%2/3
$sha || $branch
MC/DC0%0/2
$sha || $branch
$sha
$branch
Truth table66%2/3
A || B
A= $shaB= $branch
| |||||||||||||||||||||||||||||
| 196 | 13 | ▶ | $self->{patchdescr} = $describe || $branch; | ||||||||||||||||||||||||||
|
Condition33%1/3
$describe || $branch
MC/DC0%0/2
$describe || $branch
$describe
$branch
Truth table33%1/3
A || B
A= $describeB= $branch
| |||||||||||||||||||||||||||||
| 197 | 13 | return $self->{patchlevel}; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | # There does not seem to be a '.patch', try 'patchlevel.h' | ||||||||||||||||||||||||||||
| 202 | 0 | local *PATCHLEVEL_H; | |||||||||||||||||||||||||||
| 203 | 0 | my $patchlevel_h = File::Spec->catfile( $self->{ddir}, 'patchlevel.h' ); | |||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ( open PATCHLEVEL_H, "< $patchlevel_h" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 0 | my $declaration_seen = 0; | |||||||||||||||||||||||||||
| 206 | 0 | ▶ | while ( <PATCHLEVEL_H> ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 0 | ▶ | $declaration_seen ||= /local_patches\[\]/; | ||||||||||||||||||||||||||
|
Condition0%0/3
$declaration_seen ||= /local_patches\[\]/
MC/DC0%0/2
$declaration_seen ||= /local_patches\[\]/
$declaration_seen
/local_patches\[\]/
Truth table0%0/3
A ||= B
A= $declaration_seenB= /local_patches\[\]/
| |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | $declaration_seen && /^\s+,"(?:DEVEL|MAINT)(\d+)|(RC\d+)"/ or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$declaration_seen and /^\s+,"(?:DEVEL|MAINT)(\d+)|(RC\d+)"/
MC/DC0%0/2
$declaration_seen and /^\s+,"(?:DEVEL|MAINT)(\d+)|(RC\d+)"/
$declaration_seen
/^\s+,"(?:DEVEL|MAINT)(\d+)|(RC\d+)"/
Truth table0%0/3
A and B
A= $declaration_seenB= /^\s+,"(?:DEVEL|MAINT)(\d+)|(RC\d+)"/
| |||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $patch_level = $1 || $2 || '?????'; | ||||||||||||||||||||||||||
|
Condition0%0/5
$1 || $2 || '?????'
$1 or $2
MC/DC0%0/2
$1 || $2 || '?????'
$1
$2
Truth table0%0/3
A or B
A= $1B= $2
| |||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ( $patch_level =~ /^RC/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 0 | $patch_level = $self->version_from_patchlevel_h . | |||||||||||||||||||||||||||
| 212 | "-$patch_level"; | ||||||||||||||||||||||||||||
| 213 | } else { | ||||||||||||||||||||||||||||
| 214 | 0 | $patch_level++; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | # save 'patchlevel.h' mtime, so you can set it on '.patch' | ||||||||||||||||||||||||||||
| 218 | 0 | my $mtime = ( stat PATCHLEVEL_H )[9]; | |||||||||||||||||||||||||||
| 219 | 0 | close PATCHLEVEL_H; | |||||||||||||||||||||||||||
| 220 | # Now create '.patch' and return if $patch_level | ||||||||||||||||||||||||||||
| 221 | # The patchlevel is off by one in snapshots | ||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ( $patch_level && $patch_level !~ /-RC\d+$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$patch_level and not $patch_level =~ /-RC\d+$/
MC/DC0%0/2
$patch_level and not $patch_level =~ /-RC\d+$/
$patch_level
not $patch_level =~ /-RC\d+$/
Truth table0%0/3
A and not(B)
A= $patch_levelB= not $patch_level =~ /-RC\d+$/
| |||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if ( open DOTPATCH, "> $dot_patch" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | 0 | print DOTPATCH "$patch_level\n"; | |||||||||||||||||||||||||||
| 225 | 0 | close DOTPATCH; # no use generating the error | |||||||||||||||||||||||||||
| 226 | 0 | utime $mtime, $mtime, $dot_patch; | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | 0 | $self->{patchlevel} = $patch_level; | |||||||||||||||||||||||||||
| 229 | 0 | return $self->{patchlevel}; | |||||||||||||||||||||||||||
| 230 | } else { | ||||||||||||||||||||||||||||
| 231 | 0 | $self->{patchlevel} = $patch_level; | |||||||||||||||||||||||||||
| 232 | return $self->{patchlevel} | ||||||||||||||||||||||||||||
| 233 | 0 | } | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | 0 | return undef; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | =head2 version_from_patchlevel_h( $ddir ) | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | C<version_from_patchlevel_h()> returns a "dotted" version as derived | ||||||||||||||||||||||||||||
| 241 | from the F<patchlevel.h> file in the distribution. | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | =cut | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub version_from_patchlevel_h { | ||||||||||||||||||||||||||
|
Subroutine
version_from_patchlevel_h: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 246 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | require Test::Smoke::Util; | |||||||||||||||||||||||||||
| 249 | 0 | return Test::Smoke::Util::version_from_patchlevel_h( $self->{ddir} ); | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | =head2 is_git_dir() | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | Checks, in a git way, if we are in a real git repository directory. | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | =cut | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | ▶ | sub is_git_dir { | ||||||||||||||||||||||||||
|
Subroutine
is_git_dir: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 259 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 0 | my $gitbin = whereis('git'); | |||||||||||||||||||||||||||
| 262 | 0 | ▶ | if (!$gitbin) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | 0 | $self->log_debug("Could not find a git-binary to run for 'is_git_dir'"); | |||||||||||||||||||||||||||
| 264 | 0 | return 0; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | 0 | $self->log_debug("Found '$gitbin' for 'is_git_dir'"); | |||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 0 | my $git = Test::Smoke::Util::Execute->new( | |||||||||||||||||||||||||||
| 269 | command => $gitbin, | ||||||||||||||||||||||||||||
| 270 | verbose => $self->verbose, | ||||||||||||||||||||||||||||
| 271 | ); | ||||||||||||||||||||||||||||
| 272 | 0 | my $out = $git->run( | |||||||||||||||||||||||||||
| 273 | 'rev-parse' => '--is-inside-work-tree', | ||||||||||||||||||||||||||||
| 274 | '2>&1' | ||||||||||||||||||||||||||||
| 275 | ); | ||||||||||||||||||||||||||||
| 276 | 0 | $self->log_debug("git rev-parse --is-inside-work-tree: " . $out); | |||||||||||||||||||||||||||
| 277 | 0 | ▶ | return $out eq 'true' ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | =head2 make_dot_patch | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | If this is a git repo, run the C<< Porting/make_dot_patch.pl >> to generate the | ||||||||||||||||||||||||||||
| 283 | .patch file | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | =cut | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 4 | ▶ | sub make_dot_patch { | ||||||||||||||||||||||||||
|
Subroutine
make_dot_patch: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 288 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | 4 | my $mk_dot_patch = Test::Smoke::Util::Execute->new( | |||||||||||||||||||||||||||
| 291 | command => "$^X", | ||||||||||||||||||||||||||||
| 292 | verbose => $self->verbose, | ||||||||||||||||||||||||||||
| 293 | ); | ||||||||||||||||||||||||||||
| 294 | 4 | my $perlout = $mk_dot_patch->run("Porting/make_dot_patch.pl", ">", ".patch"); | |||||||||||||||||||||||||||
| 295 | 4 | $self->log_debug($perlout); | |||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | =head2 $syncer->clean_from_directory( $source_dir[, @leave_these] ) | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | C<clean_from_directory()> uses File::Find to get the contents of | ||||||||||||||||||||||||||||
| 301 | C<$source_dir> and compare these to {ddir} and remove all other files. | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | The contents of @leave_these should be in "MANIFEST-format" | ||||||||||||||||||||||||||||
| 304 | (See L<Test::Smoke::SourceTree>). | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | =cut | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 2 | ▶ | sub clean_from_directory { | ||||||||||||||||||||||||||
|
Subroutine
clean_from_directory: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||
| 309 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 310 | 2 | my ($clean_dir, @leave_these) = @_; | |||||||||||||||||||||||||||
| 311 | 2 | my $this_dir = abs_path(File::Spec->curdir); | |||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 2 | ▶ | my $source_dir = File::Spec->file_name_is_absolute($clean_dir) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | ? $clean_dir | ||||||||||||||||||||||||||||
| 315 | : File::Spec->rel2abs($clean_dir, $this_dir); | ||||||||||||||||||||||||||||
| 316 | 2 | $self->log_debug("[clean_from_directory($this_dir)] $clean_dir => $source_dir\n"); | |||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 2 | require Test::Smoke::SourceTree; | |||||||||||||||||||||||||||
| 319 | 2 | my $tree = Test::Smoke::SourceTree->new($source_dir, $self->{v}); | |||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 0 | my %orig_dir = map { ( $_ => 1) } @leave_these; | |||||||||||||||||||||||||||
| 322 | 16 | ▶ | File::Find::find( sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 323 | 16 | ▶ | return unless -f; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | 12 | my $file = $tree->abs2mani( $File::Find::name ); | |||||||||||||||||||||||||||
| 325 | 12 | $orig_dir{ $file } = 1; | |||||||||||||||||||||||||||
| 326 | 2 | }, $source_dir ); | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 2 | $tree = Test::Smoke::SourceTree->new( $self->{ddir}, $self->{v} ); | |||||||||||||||||||||||||||
| 329 | 16 | ▶ | File::Find::find( sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=21.9
| |||||||||||||||||||||||||||||
| 330 | 16 | ▶ | return unless -f; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | 12 | my $file = $tree->abs2mani( $File::Find::name ); | |||||||||||||||||||||||||||
| 332 | 12 | ▶ | return if exists $orig_dir{ $file }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 333 | 0 | ▶ | 1 while unlink $_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 334 | 0 | ▶ | $self->log_debug("Unlink '$file': " . (-e $_ ? "$!" : "ok")); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 335 | 2 | }, $self->{ddir} ); | |||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | =head2 $syncer->pre_sync | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | C<pre_sync()> should be called by the C<sync()> methods to setup the | ||||||||||||||||||||||||||||
| 341 | sync environment. Currently only useful on I<OpenVMS>. | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | =cut | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 10 | ▶ | sub pre_sync { | ||||||||||||||||||||||||||
|
Subroutine
pre_sync: called CC=2 SCAR=13.0
Pod
documented
| |||||||||||||||||||||||||||||
| 346 | 10 | ▶ | return 1 unless $^O eq 'VMS'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 347 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 348 | 0 | require Test::Smoke::Util; | |||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 0 | Test::Smoke::Util::set_vms_rooted_logical( TSP5SRC => $self->{ddir} ); | |||||||||||||||||||||||||||
| 351 | 0 | $self->{vms_ddir} = $self->{ddir}; | |||||||||||||||||||||||||||
| 352 | 0 | $self->{ddir} = 'TSP5SRC:[000000]'; | |||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | =head2 $syncer->post_sync | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | C<post_sync()> should be called by the C<sync()> methods to unset the | ||||||||||||||||||||||||||||
| 358 | sync environment. Currently only useful on I<OpenVMS>. | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | =cut | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 9 | ▶ | sub post_sync { | ||||||||||||||||||||||||||
|
Subroutine
post_sync: called CC=4 SCAR=26.2
Pod
documented
| |||||||||||||||||||||||||||||
| 363 | 9 | ▶ | return 1 unless $^O eq 'VMS'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 364 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 0 | ▶ | ( my $logical = $self->{ddir} || '' ) =~ s/:\[000000\]$//; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'ddir'} || ''
MC/DC0%0/1
$self->{'ddir'} || ''
$self->{'ddir'}
Truth table0%0/2
A
A= $self->{'ddir'}
| |||||||||||||||||||||||||||||
| 367 | 0 | ▶ | return unless $logical; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 368 | 0 | my $result = system "DEASSIGN/JOB $logical"; | |||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | 0 | $self->{ddir} = delete $self->{vms_ddir}; | |||||||||||||||||||||||||||
| 371 | 0 | return $result == 0; | |||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | 12 | 1; | |||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | (c) 2002-2013, All rights reserved. | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | * Abe Timmerman <abeltje@cpan.org> | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 383 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | See: | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | * <http://www.perl.com/perl/misc/Artistic.html>, | ||||||||||||||||||||||||||||
| 388 | * <http://www.gnu.org/copyleft/gpl.html> | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 391 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 392 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | =cut | ||||||||||||||||||||||||||||