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

filter: Statementstmt 26.8% 11 / 41 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 24.1% 15 / 62 CC 9 SCAR 42.2
CC
9
Cov
19%
sync
90.0
BEGIN
1.0
BEGIN
1.0
CRAP 67.8
« blib/lib/Test/Smoke/App/ConfigSmoke/Scheduler.pm ↑ Summary blib/lib/Test/Smoke/Mailer.pm »
1 package Test::Smoke::Syncer::Forest;
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::Forest
10  
11 This handles syncing by setting up a master directory that is in sync
12 with either a snapshot or the repository. Then it creates a copy of
13 this master directory as a hardlink forest and the B<regenheaders.pl>
14 script is run (if found). Now the source-tree should be up to date
15 and ready to be copied as a hardlink forest again, to its final
16 destination.
17  
18 Thanks to Nicholas Clark for donating this idea.
19  
20 =cut
21  
22 =head2 Test::Smoke::Syncer::Forest->new( %args )
23  
24 Keys for C<%args>:
25  
26 * All keys from the other methods (depending on {fsync})
27 * fsync: which master sync method is to be used
28 * mdir: master directory
29 * fdir: intermediate directory (first hardlink forest)
30  
31 =cut
32  
33 =head2 $syncer->sync( )
34  
35 C<sync()> starts with a "traditional" sync according to {ftype} in {mdir}.
36 It then creates a copy of {mdir} in {fdir} with hardlinks an tries to run
37 the B<regen_headers.pl> script in {fdir}. This directory should now contain
38 an up to date (working) source-tree wich again using hardlinks is copied
39 to the destination directory {ddir}.
40  
41  
42 =cut
43  
44 0 ▶sub sync {
Subroutine sync: not called CC=9 SCAR=45.0
Pod documented
45 0 my $self = shift;
46  
47 0 my %args = map { ( $_ => $self->{ $_ } ) } keys %$self;
48 0 $args{ddir} = $self->{mdir};
49 0 ▶ $self->{v} and print "Prepare to sync ($self->{fsync}|$args{ddir})\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"v"} and print qq[Prepare to sync ($self->{"fsync"}|$args{"ddir"})\n] 0 0 0
50 0 my $syncer = Test::Smoke::Syncer->new( $self->{fsync}, \%args );
51 0 $syncer->sync;
52  
53 # Now copy the master
54 0 $args{ddir} = $self->{fdir};
55 0 $args{hdir} = $self->{mdir};
56 0 ▶ $self->{v} and print "Prepare to sync (hardlink|$args{ddir})\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"v"} and print qq[Prepare to sync (hardlink|$args{"ddir"})\n] 0 0 0
57 0 $syncer = Test::Smoke::Syncer->new( hardlink => \%args );
58 0 $syncer->sync;
59  
60 # now try to run the 'regen_headers.pl' script
61 0 ▶ if ( -e File::Spec->catfile( $self->{fdir}, 'regen_headers.pl' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "File::Spec"->catfile($self->{"fdir"}, "regen_headers.pl")) 0 0 0
62 0 ▶ $self->{v} and print "Run 'regen_headers.pl' ($self->{fdir})\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"v"} and print qq[Run 'regen_headers.pl' ($self->{"fdir"})\n] 0 0 0
63 0 my $cwd = Cwd::cwd();
64 0 ▶ chdir $self->{fdir} or do {
Branch: 1 branch
BranchTrueFalseTotal
chdir $self->{"fdir"} or do { require Carp; Carp::croak(qq[Cannot chdir($self->{"fdir"}) in forest: $!]) } 0 0 0
65 0 require Carp;
66 0 Carp::croak( "Cannot chdir($self->{fdir}) in forest: $!" );
67 };
68 0 ▶ system( "$^X regen_headers.pl" ) == 0 or do {
Branch: 1 branch
BranchTrueFalseTotal
system("$^X regen_headers.pl") == 0 or do { require Carp; Carp::carp("Error while running 'regen_headers.pl'") } 0 0 0
69 0 require Carp;
70 0 Carp::carp( "Error while running 'regen_headers.pl'" );
71 };
72 0 ▶ chdir $cwd or do {
Branch: 1 branch
BranchTrueFalseTotal
chdir $cwd or do { require Carp; Carp::croak("Cannot chdir($cwd) back: $!") } 0 0 0
73 0 require Carp;
74 0 Carp::croak( "Cannot chdir($cwd) back: $!" );
75 };
76 }
77  
78 0 $args{ddir} = $self->{ddir};
79 0 $args{hdir} = $self->{fdir};
80 0 ▶ $self->{v} and print "Prepare to sync (hardlink|$args{ddir})\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"v"} and print qq[Prepare to sync (hardlink|$args{"ddir"})\n] 0 0 0
81 0 $syncer = Test::Smoke::Syncer->new( hardlink => \%args );
82 0 my $plevel = $syncer->sync;
83  
84 0 return $plevel;
85 }
86  
87 12 1;
88  
89 =head1 COPYRIGHT
90  
91 (c) 2002-2013, All rights reserved.
92  
93 * Abe Timmerman <abeltje@cpan.org>
94  
95 This library is free software; you can redistribute it and/or modify
96 it under the same terms as Perl itself.
97  
98 See:
99  
100 * <http://www.perl.com/perl/misc/Artistic.html>,
101 * <http://www.gnu.org/copyleft/gpl.html>
102  
103 This program is distributed in the hope that it will be useful,
104 but WITHOUT ANY WARRANTY; without even the implied warranty of
105 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
106  
107 =cut
« blib/lib/Test/Smoke/App/ConfigSmoke/Scheduler.pm ↑ Summary blib/lib/Test/Smoke/Mailer.pm »