blib/lib/Test/Smoke/Syncer/Hardlink.pm

filter: Statementstmt 96.7% 30 / 31 Branchbran 55.0% 11 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 82.4% 47 / 57 CC 11 SCAR 21.1
CC
11
Cov
80%
__ANON__
12.4
sync
3.2
BEGIN
1.0
CRAP 8.2
« blib/lib/Test/Smoke/SourceTree.pm ↑ Summary blib/lib/Test/Smoke/PostQueue.pm »
1 package Test::Smoke::Syncer::Hardlink;
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::Hardlink
10  
11 This handles syncing by copying the source-tree from a local directory
12 using the B<link> function. This can be used as an alternative for
13 B<make distclean>.
14  
15 Thanks to Nicholas Clark for donating this suggestion!
16  
17 =cut
18  
19 12 require File::Find;
20  
21 =head2 Test::Smoke::Syncer::Hardlink->new( %args )
22  
23 Keys for C<%args>:
24  
25 * ddir: destination directory
26 * hdir: source directory
27 * v: verbose
28  
29 =cut
30  
31 =head2 $syncer->sync( )
32  
33 C<sync()> uses the B<File::Find> module to make the hardlink forest in {ddir}.
34  
35 =cut
36  
37 2 ▶sub sync {
Subroutine sync: called CC=3 SCAR=11.5
Pod documented
38 2 my $self = shift;
39  
40 2 $self->pre_sync;
41 2 ▶ require File::Copy unless $self->{haslink};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"haslink"} 1 1 2
42  
43 2 ▶ -d $self->{ddir} or File::Path::mkpath( $self->{ddir} );
Branch: 1 branch
BranchTrueFalseTotal
-d $self->{"ddir"} or File::Path::mkpath($self->{"ddir"}) 0 2 2
44  
45 2 my $source_dir = File::Spec->canonpath( $self->{hdir} );
46  
47 16 ▶ File::Find::find( sub {
Subroutine __ANON__: called CC=9 SCAR=25.1
48 16 my $dest = File::Spec->abs2rel( $File::Find::name, $source_dir );
49 # nasty thing in older File::Spec::Win32::abs2rel()
50 16 ▶ $^O eq 'MSWin32' and $dest =~ s|^[a-z]:(?![/\\])||i;
Branch: 1 branch
BranchTrueFalseTotal
$^O eq "MSWin32" and $dest =~ s(^[a-z]:(?![/\\]))[]i 0 16 16
51 16 $dest = File::Spec->catfile( $self->{ddir}, $dest );
52 16 ▶ if ( -d ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $_) { } 4 12 16
53 4 mkdir $dest, (stat _)[2] & 07777;
54 } else {
55 12 ▶ -e $dest and 1 while unlink $dest;
Branch: 2 branches
BranchTrueFalseTotal
unlink $dest and do { -e $dest and '???' } 0 12 12
-e $dest and '???' 0 0 0
56 12 ▶ $self->{v} > 1 and print "link $_ $dest";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"v"} > 1 and print "link $_ $dest" 0 12 12
57 my $ok = $self->{haslink}
58 12 ▶ ? link $_, $dest
Branch: 1 branch
BranchTrueFalseTotal
$self->{'haslink'} ? : 6 6 12
59 : File::Copy::copy( $_, $dest );
60 12 ▶ if ( $self->{v} > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"v"} > 1) 0 12 12
61 0 ▶ print $ok ? " OK\n" : " $!\n";
Branch: 1 branch
BranchTrueFalseTotal
$ok ? : 0 0 0
62 }
63 }
64 2 }, $source_dir );
65  
66 2 $self->clean_from_directory( $source_dir );
67  
68 2 $self->post_sync;
69 2 return $self->check_dot_patch();
70 }
71  
72 12 1;
73  
74 =head1 COPYRIGHT
75  
76 (c) 2002-2013, All rights reserved.
77  
78 * Abe Timmerman <abeltje@cpan.org>
79  
80 This library is free software; you can redistribute it and/or modify
81 it under the same terms as Perl itself.
82  
83 See:
84  
85 * <http://www.perl.com/perl/misc/Artistic.html>,
86 * <http://www.gnu.org/copyleft/gpl.html>
87  
88 This program is distributed in the hope that it will be useful,
89 but WITHOUT ANY WARRANTY; without even the implied warranty of
90 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
91  
92 =cut
« blib/lib/Test/Smoke/SourceTree.pm ↑ Summary blib/lib/Test/Smoke/PostQueue.pm »