lib/ExtUtils/Command/MM.pm

filter: Statementstmt 31.5% 30 / 95 Branchbran 17.6% 6 / 34 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 30.7% 4 / 13 Podpod 87.5% 7 / 8 totaltotal 27.3% 47 / 172 CC 23 SCAR 37.7
CC
23
Cov
25%
pod2man
91.7
perllocal_install
20.0
mtime
7.4
CRAP 43.5
« lib/ExtUtils/MakeMaker.pm ↑ Summary lib/ExtUtils/MM_Win32.pm »
1 package ExtUtils::Command::MM;
2  
3 2 require 5.006;
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 require Exporter;
9 2 our @ISA = qw(Exporter);
10  
11 2 our @EXPORT = qw(test_harness pod2man perllocal_install uninstall
12 warn_if_old_packlist test_s cp_nonempty);
13 2 our $VERSION = '7.78';
14 2 $VERSION =~ tr/_//d;
15  
16 2 my $Is_VMS = $^O eq 'VMS';
17  
18 0 ▶sub mtime {
Subroutine mtime: not called CC=3 SCAR=20.0
Pod undocumented
19 2 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 0 local $@;
21 0 *mtime = (eval { require Time::HiRes } && defined &Time::HiRes::stat)
22 0 ▶ ? sub { (Time::HiRes::stat($_[0]))[9] }
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 0 ▶ : sub { ( stat($_[0]))[9] }
Subroutine __ANON__: not called CC=1 SCAR=6.9
24 0 ▶ ;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require Time::HiRes } } && defined &Time::HiRes::stat ? : 0 0 0
Condition0%0/3
eval { do { require Time::HiRes } } and defined &Time::HiRes::stat
!ll&&!rl&&r
000
MC/DC0%0/2
eval { do { require Time::HiRes } } and defined &Time::HiRes::stat
eval { do { require Time::HiRes } } defined &Time::HiRes::stat
Truth table0%0/3
A and B
A= eval { do { require Time::HiRes } }B= defined &Time::HiRes::stat
ABresult
0X0
100
111
25 0 goto &mtime;
26 }
27  
28 =head1 NAME
29  
30 ExtUtils::Command::MM - Commands for the MM's to use in Makefiles
31  
32 =head1 SYNOPSIS
33  
34 perl "-MExtUtils::Command::MM" -e "function" "--" arguments...
35  
36  
37 =head1 DESCRIPTION
38  
39 B<FOR INTERNAL USE ONLY!> The interface is not stable.
40  
41 ExtUtils::Command::MM encapsulates code which would otherwise have to
42 be done with large "one" liners.
43  
44 Any $(FOO) used in the examples are make variables, not Perl.
45  
46 =over 4
47  
48 =item B<test_harness>
49  
50 test_harness($verbose, @test_libs);
51  
52 Runs the tests on @ARGV via Test::Harness passing through the $verbose
53 flag. Any @test_libs will be unshifted onto the test's @INC.
54  
55 @test_libs are run in alphabetical order.
56  
57 =cut
58  
59 0 ▶sub test_harness {
Subroutine test_harness: not called CC=1 SCAR=6.9
Pod documented
60 0 require Test::Harness;
61 0 require File::Spec;
62  
63 0 $Test::Harness::verbose = shift;
64  
65 # Because Windows doesn't do this for us and listing all the *.t files
66 # out on the command line can blow over its exec limit.
67 0 require ExtUtils::Command;
68 0 my @argv = ExtUtils::Command::expand_wildcards(@ARGV);
69  
70 0 local @INC = @INC;
71 0 unshift @INC, map { File::Spec->rel2abs($_) } @_;
72 0 Test::Harness::runtests(sort { lc $a cmp lc $b } @argv);
73 }
74  
75  
76  
77 =item B<pod2man>
78  
79 pod2man( '--option=value',
80 $podfile1 => $manpage1,
81 $podfile2 => $manpage2,
82 ...
83 );
84  
85 # or args on @ARGV
86  
87 pod2man() is a function performing most of the duties of the pod2man
88 program. Its arguments are exactly the same as pod2man as of 5.8.0
89 with the addition of:
90  
91 --perm_rw octal permission to set the resulting manpage to
92  
93 And the removal of:
94  
95 --verbose/-v
96 --help/-h
97  
98 If no arguments are given to pod2man it will read from @ARGV.
99  
100 If Pod::Man is unavailable, this function will warn and return undef.
101  
102 =cut
103  
104 2 ▶sub pod2man {
Subroutine pod2man: called CC=15 SCAR=45.2
Pod documented
105 2 ▶ local @ARGV = @_ ? @_ : @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 1 1 2
106  
107 {
108 2 local $@;
109 2 ▶ if( !eval { require Pod::Man } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require Pod::Man } }) 1 1 2
110 1 warn "Pod::Man is not available: $@".
111 "Man pages will not be generated during this install.\n";
112 1 return 0;
113 }
114 }
115 1 require Getopt::Long;
116  
117 # We will cheat and just use Getopt::Long. We fool it by putting
118 # our arguments into @ARGV. Should be safe.
119 1 my %options = ();
120 1 Getopt::Long::config ('bundling_override');
121 1 Getopt::Long::GetOptions (\%options,
122 'section|s=s', 'release|r=s', 'center|c=s',
123 'date|d=s', 'fixed=s', 'fixedbold=s', 'fixeditalic=s',
124 'fixedbolditalic=s', 'official|o', 'quotes|q=s', 'lax|l',
125 'name|n=s', 'perm_rw=i', 'utf8|u'
126 );
127 1 ▶ delete $options{utf8} unless $Pod::Man::VERSION >= 2.17;
Branch: 1 branch
BranchTrueFalseTotal
unless $Pod::Man::VERSION >= "2.17" 0 1 1
128  
129 # If there's no files, don't bother going further.
130 1 ▶ return 0 unless @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
unless @ARGV 1 0 1
131  
132 # Official sets --center, but don't override things explicitly set.
133 0 ▶ if ($options{official} && !defined $options{center}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"official"} and not defined $options{"center"}) 0 0 0
Condition0%0/3
$options{"official"} and not defined $options{"center"}
!ll&&!rl&&r
000
MC/DC0%0/2
$options{"official"} and not defined $options{"center"}
$options{"official"} not defined $options{"center"}
Truth table0%0/3
A and not(B)
A= $options{"official"}B= not defined $options{"center"}
ABresult
0X0
100
111
134 0 $options{center} = q[Perl Programmer's Reference Guide];
135 }
136  
137 # This isn't a valid Pod::Man option and is only accepted for backwards
138 # compatibility.
139 0 delete $options{lax};
140 0 my $count = scalar @ARGV / 2;
141 0 ▶ my $plural = $count == 1 ? 'document' : 'documents';
Branch: 1 branch
BranchTrueFalseTotal
$count == 1 ? : 0 0 0
142 0 print "Manifying $count pod $plural\n";
143  
144 0 ▶ do {{ # so 'next' works
Branch: 1 branch
BranchTrueFalseTotal
@ARGV and do { do { { () = splice(@ARGV, 0, 2); next if -e $man and mtime($man) > mtime($pod) and mtime($man) > mtime("Makefile"); my $parser = "Pod::Man"->new(%options); $parser->parse_from_file($pod, $man) or do { warn "Could not install $man\n"; next }; if (exists $options{"perm_rw"}) { chmod oct $options{"perm_rw"}, $man or do { warn qq[chmod $options{"perm_rw"} ${man}: $!\n]; next }; } ; } } } 0 0 0
145 0 my ($pod, $man) = splice(@ARGV, 0, 2);
146  
147 0 ▶ next if ((-e $man) &&
Branch: 1 branch
BranchTrueFalseTotal
if -e $man and mtime($man) > mtime($pod) and mtime($man) > mtime("Makefile") 0 0 0
Condition0%0/6
-e $man and mtime($man) > mtime($pod) and mtime($man) > mtime("Makefile")
!ll&&!rl&&r
000
-e $man and mtime($man) > mtime($pod)
!ll&&!rl&&r
000
MC/DC0%0/3
-e $man and mtime($man) > mtime($pod) and mtime($man) > mtime("Makefile")
-e $man mtime($man) > mtime($pod) mtime($man) > mtime("Makefile")
Truth table0%0/4
A and B and C
A= -e $manB= mtime($man) > mtime($pod)C= mtime($man) > mtime("Makefile")
ABCresult
0XX0
10X0
1100
1111
148 (mtime($man) > mtime($pod)) &&
149 (mtime($man) > mtime("Makefile")));
150  
151 0 my $parser = Pod::Man->new(%options);
152 $parser->parse_from_file($pod, $man)
153 0 ▶ or do { warn("Could not install $man\n"); next };
Branch: 1 branch
BranchTrueFalseTotal
$parser->parse_from_file($pod, $man) or do { warn "Could not install $man\n"; next } 0 0 0
154  
155 0 ▶ if (exists $options{perm_rw}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $options{"perm_rw"}) 0 0 0
156 chmod(oct($options{perm_rw}), $man)
157 0 ▶ or do { warn("chmod $options{perm_rw} $man: $!\n"); next };
Branch: 1 branch
BranchTrueFalseTotal
chmod oct $options{"perm_rw"}, $man or do { warn qq[chmod $options{"perm_rw"} ${man}: $!\n]; next } 0 0 0
158 }
159 }} while @ARGV;
160  
161 0 return 1;
162 }
163  
164  
165 =item B<warn_if_old_packlist>
166  
167 perl "-MExtUtils::Command::MM" -e warn_if_old_packlist <somefile>
168  
169 Displays a warning that an old packlist file was found. Reads the
170 filename from @ARGV.
171  
172 =cut
173  
174 0 ▶sub warn_if_old_packlist {
Subroutine warn_if_old_packlist: not called CC=2 SCAR=17.9
Pod documented
175 0 my $packlist = $ARGV[0];
176  
177 0 ▶ return unless -f $packlist;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $packlist 0 0 0
178 0 print <<"PACKLIST_WARNING";
179 WARNING: I have found an old package in
180 $packlist.
181 Please make sure the two installations are not conflicting
182 PACKLIST_WARNING
183  
184 }
185  
186  
187 =item B<perllocal_install>
188  
189 perl "-MExtUtils::Command::MM" -e perllocal_install
190 <type> <module name> <key> <value> ...
191  
192 # VMS only, key|value pairs come on STDIN
193 perl "-MExtUtils::Command::MM" -e perllocal_install
194 <type> <module name> < <key>|<value> ...
195  
196 Prints a fragment of POD suitable for appending to perllocal.pod.
197 Arguments are read from @ARGV.
198  
199 'type' is the type of what you're installing. Usually 'Module'.
200  
201 'module name' is simply the name of your module. (Foo::Bar)
202  
203 Key/value pairs are extra information about the module. Fields include:
204  
205 installed into which directory your module was out into
206 LINKTYPE dynamic or static linking
207 VERSION module version number
208 EXE_FILES any executables installed in a space separated
209 list
210  
211 =cut
212  
213 0 ▶sub perllocal_install {
Subroutine perllocal_install: not called CC=4 SCAR=30.0
Pod documented
214 0 my($type, $name) = splice(@ARGV, 0, 2);
215  
216 # VMS feeds args as a piped file on STDIN since it usually can't
217 # fit all the args on a single command line.
218 0 ▶ my @mod_info = $Is_VMS ? split /\|/, <STDIN>
Branch: 1 branch
BranchTrueFalseTotal
$Is_VMS ? : 0 0 0
219 : @ARGV;
220  
221 0 my $pod;
222 0 ▶ my $time = gmtime($ENV{SOURCE_DATE_EPOCH} || time);
Condition0%0/2
$ENV{'SOURCE_DATE_EPOCH'} || time
l!l
00
MC/DC0%0/1
$ENV{'SOURCE_DATE_EPOCH'} || time
$ENV{'SOURCE_DATE_EPOCH'}
Truth table0%0/2
A
A= $ENV{'SOURCE_DATE_EPOCH'}
Aresult
11
00
223 0 $pod = sprintf <<'POD', scalar($time), $type, $name, $name;
224 =head2 %s: C<%s> L<%s|%s>
225  
226 =over 4
227  
228 POD
229  
230 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
@mod_info and do { do { () = splice(@mod_info, 0, 2); $pod .= " =item *\n\n C<${key}: $val>\n\n" } } 0 0 0
231 0 my($key, $val) = splice(@mod_info, 0, 2);
232  
233 0 $pod .= <<POD
234 =item *
235  
236 C<$key: $val>
237  
238 POD
239  
240 } while(@mod_info);
241  
242 0 $pod .= "=back\n\n";
243 0 $pod =~ s/^ //mg;
244 0 print $pod;
245  
246 0 return 1;
247 }
248  
249 =item B<uninstall>
250  
251 perl "-MExtUtils::Command::MM" -e uninstall <packlist>
252  
253 A wrapper around ExtUtils::Install::uninstall(). Warns that
254 uninstallation is deprecated and doesn't actually perform the
255 uninstallation.
256  
257 =cut
258  
259 0 ▶sub uninstall {
Subroutine uninstall: not called CC=1 SCAR=6.9
Pod documented
260 0 my($packlist) = shift @ARGV;
261  
262 0 require ExtUtils::Install;
263  
264 0 print <<'WARNING';
265  
266 Uninstall is unsafe and deprecated, the uninstallation was not performed.
267 We will show what would have been done.
268  
269 WARNING
270  
271 0 ExtUtils::Install::uninstall($packlist, 1, 1);
272  
273 0 print <<'WARNING';
274  
275 Uninstall is unsafe and deprecated, the uninstallation was not performed.
276 Please check the list above carefully, there may be errors.
277 Remove the appropriate files manually.
278 Sorry for the inconvenience.
279  
280 WARNING
281  
282 }
283  
284 =item B<test_s>
285  
286 perl "-MExtUtils::Command::MM" -e test_s <file>
287  
288 Tests if a file exists and is not empty (size > 0).
289 I<Exits> with 0 if it does, 1 if it does not.
290  
291 =cut
292  
293 0 ▶sub test_s {
Subroutine test_s: not called CC=2 SCAR=17.9
Pod documented
294 0 ▶ exit(-s $ARGV[0] ? 0 : 1);
Branch: 1 branch
BranchTrueFalseTotal
-s $ARGV[0] ? : 0 0 0
295 }
296  
297 =item B<cp_nonempty>
298  
299 perl "-MExtUtils::Command::MM" -e cp_nonempty <srcfile> <dstfile> <perm>
300  
301 Tests if the source file exists and is not empty (size > 0). If it is not empty
302 it copies it to the given destination with the given permissions.
303  
304 =back
305  
306 =cut
307  
308 0 ▶sub cp_nonempty {
Subroutine cp_nonempty: not called CC=2 SCAR=17.9
Pod documented
309 0 my @args = @ARGV;
310 0 ▶ return 0 unless -s $args[0];
Branch: 1 branch
BranchTrueFalseTotal
unless -s $args[0] 0 0 0
311 0 require ExtUtils::Command;
312 {
313 0 local @ARGV = @args[0,1];
314 0 ExtUtils::Command::cp(@ARGV);
315 }
316 {
317 0 local @ARGV = @args[2,1];
318 0 ExtUtils::Command::chmod(@ARGV);
319 }
320 }
321  
322  
323 2 1;
« lib/ExtUtils/MakeMaker.pm ↑ Summary lib/ExtUtils/MM_Win32.pm »