ShipIt/ProjectType/AutoConf.pm

filter: Statementstmt 22.5% 16 / 71 Branchbran 0.0% 0 / 54 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 45.4% 5 / 11 Podpod 60.0% 3 / 5 totaltotal 17.0% 24 / 141 CC 28 SCAR 48.5
CC
28
Cov
13%
_build_tempdist
210.0
disttest
156.0
new
6.0
CRAP 127.8
↑ Summary ShipIt/Step/CheckChangeLog.pm »
1 package ShipIt::ProjectType::AutoConf;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use base 'ShipIt::ProjectType';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use ShipIt::Util qw(slurp write_file tempdir_obj);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use File::Copy ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # factory when called directly.
9 # returns undef if not a perl project, otherwise returns
10 # ::MakeMaker or ::ModuleBuild instance.
11 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
12 0 my ($class) = @_;
13 0 ▶ return undef unless -e "configure.ac";
Branch: 1 branch
BranchTrueFalseTotal
unless -e "configure.ac" 0 0 0
14 0 my $self = $class->SUPER::new;
15 0 return $self;
16 }
17  
18 0 ▶sub current_version {
Subroutine current_version: not called CC=2 SCAR=17.9
Pod undocumented
19 0 my ($self) = @_;
20 0 my $conf = slurp("configure.ac");
21 0 ▶ die "No AC_INIT found" unless
Branch: 1 branch
BranchTrueFalseTotal
unless $conf =~ /^AC_INIT\((.+?), (\S+?), .+\)/m 0 0 0
22 $conf =~ /^AC_INIT\((.+?), (\S+?), .+\)/m;
23 0 $self->{projname} = $1;
24 0 $self->{projver} = $2;
25 0 return $2;
26 }
27  
28 0 ▶sub update_version {
Subroutine update_version: not called CC=2 SCAR=17.9
Pod documented
29 0 my ($self, $newver) = @_;
30 0 my $conf = slurp("configure.ac");
31 0 ▶ $conf =~ s/^AC_INIT\((.+?), (\S+?), (.+)\)/AC_INIT($1, $newver, $3)/m
Branch: 1 branch
BranchTrueFalseTotal
$conf =~ s/^AC_INIT\((.+?), (\S+?), (.+)\)/AC_INIT($1, $newver, $3)/m or die "update_version regpexp failed" 0 0 0
32 or die "update_version regpexp failed";
33 0 write_file("configure.ac", $conf);
34 }
35  
36 0 ▶sub makedist {
Subroutine makedist: not called CC=1 SCAR=6.9
Pod documented
37 0 my $self = shift;
38 0 my $distfile = $self->_build_tempdist;
39 0 return $distfile;
40 }
41  
42 0 ▶sub disttest {
Subroutine disttest: not called CC=12 SCAR=50.5
Pod documented
43 0 my ($self) = @_;
44 0 my $distfile = $self->_build_tempdist;
45  
46 # debug,
47 0 my $size = -s $distfile;
48 0 warn "distfile = $distfile (size = $size)\n";
49  
50 0 ▶ my ($basename) = $distfile =~ m!([^/]+)$! or die;
Branch: 1 branch
BranchTrueFalseTotal
my($basename) = $distfile =~ m[([^/]+)$] or die 0 0 0
51  
52 0 my $testdir_o = tempdir_obj();
53 0 my $testdir = $testdir_o->directory;
54 0 ▶ File::Copy::copy($distfile, $testdir)
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::copy($distfile, $testdir) or die "Copy from $distfile to $testdir failed: $!\n" 0 0 0
55 or die "Copy from $distfile to $testdir failed: $!\n";
56  
57 0 my $old_cwd = getcwd;
58 0 warn "Changing to tempdir $testdir for make/make test...\n";
59 0 ▶ chdir($testdir) or die "chdir to testdir $testdir failed";
Branch: 1 branch
BranchTrueFalseTotal
chdir $testdir or die "chdir to testdir $testdir failed" 0 0 0
60 0 ▶ system("tar -zxvf $basename") and die "untar failed";
Branch: 1 branch
BranchTrueFalseTotal
system "tar -zxvf $basename" and die "untar failed" 0 0 0
61  
62 0 ▶ my ($untardir) = $basename =~ m!^(.+)\.tar\.gz$! or die;
Branch: 1 branch
BranchTrueFalseTotal
my($untardir) = $basename =~ /^(.+)\.tar\.gz$/ or die 0 0 0
63 0 ▶ die "Expected untarred dir $untardir, but not there" unless -d $untardir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $untardir 0 0 0
64 0 ▶ chdir($untardir) or die;
Branch: 1 branch
BranchTrueFalseTotal
chdir $untardir or die 0 0 0
65  
66 0 ▶ system("./configure") and die "configure during test failed";
Branch: 1 branch
BranchTrueFalseTotal
system "./configure" and die "configure during test failed" 0 0 0
67 0 ▶ system("make") and die "make during test failed";
Branch: 1 branch
BranchTrueFalseTotal
system "make" and die "make during test failed" 0 0 0
68 0 ▶ system("make", "test") and die "make test failed";
Branch: 1 branch
BranchTrueFalseTotal
system "make", "test" and die "make test failed" 0 0 0
69  
70 # restore old working directory
71 0 ▶ chdir($old_cwd) or die;
Branch: 1 branch
BranchTrueFalseTotal
chdir $old_cwd or die 0 0 0
72  
73 0 return 1;
74 }
75  
76 0 ▶sub _build_tempdist {
Subroutine _build_tempdist: not called CC=14 SCAR=53.5
77 0 my $self = shift;
78  
79 0 ▶ my $projname = $self->{projname} or die "no projname found?";
Branch: 1 branch
BranchTrueFalseTotal
my $projname = $self->{"projname"} or die "no projname found?" 0 0 0
80 0 ▶ my $projver = $self->{projver} or die "no projver found?";
Branch: 1 branch
BranchTrueFalseTotal
my $projver = $self->{"projver"} or die "no projver found?" 0 0 0
81 0 my $distfile = "$projname-$projver.tar.gz";
82  
83 # did we already build it for a DistTest step earlier?
84 0 ▶ if (my $tdir = $self->{dist_tempdirobj}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tdir = $self->{"dist_tempdirobj"}) 0 0 0
85 0 my $file = $tdir->directory . "/$distfile";
86 0 ▶ return $file if -e $file;
Branch: 1 branch
BranchTrueFalseTotal
if -e $file 0 0 0
87 }
88  
89 0 ▶ die "Distfile $distfile already exists" if -e $distfile;
Branch: 1 branch
BranchTrueFalseTotal
if -e $distfile 0 0 0
90  
91 0 ▶ if (-e "Makefile") {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "Makefile") 0 0 0
92 0 ▶ system("make", "distclean") and die "Distclean failed";
Branch: 1 branch
BranchTrueFalseTotal
system "make", "distclean" and die "Distclean failed" 0 0 0
93 }
94  
95 0 ▶ if (-x "autogen.sh") {
Branch: 1 branch
BranchTrueFalseTotal
if (-x "autogen.sh") 0 0 0
96 0 ▶ system("./autogen.sh") and die "autogen.sh failed";
Branch: 1 branch
BranchTrueFalseTotal
system "./autogen.sh" and die "autogen.sh failed" 0 0 0
97 }
98  
99 0 ▶ system("./configure") and die "configure failed";
Branch: 1 branch
BranchTrueFalseTotal
system "./configure" and die "configure failed" 0 0 0
100 0 ▶ system("make", "dist") and die "make dist failed";
Branch: 1 branch
BranchTrueFalseTotal
system "make", "dist" and die "make dist failed" 0 0 0
101  
102 0 ▶ die "Distfile $distfile doesn't exist" unless -e $distfile;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $distfile 0 0 0
103  
104 # throw object in $self, so it doesn't get rmtree'd until
105 # $self goes out of scope, later.
106 0 my $tdir = $self->{dist_tempdirobj} = tempdir_obj();
107  
108 0 ▶ File::Copy::move($distfile, $tdir->directory) or
Branch: 1 branch
BranchTrueFalseTotal
File::Copy::move($distfile, $tdir->directory) or die "Failed to move dist $distfile to tempdir" 0 0 0
109 die "Failed to move dist $distfile to tempdir";
110  
111 0 return $tdir->directory . "/$distfile";
112 }
113  
114 2 1;
↑ Summary ShipIt/Step/CheckChangeLog.pm »