3 #=======================================================================
5 # File ID: a2e25ad4-56fe-11e0-8c2f-00023faf1383
7 # Find missing Perl modules.
10 # ©opyleft 2011– Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later, see end of
12 # file for legal stuff.
13 #=======================================================================
19 use Test
::More
qw{no_plan
};
22 use lib
"$ENV{HOME}/bin/Lib/perllib";
23 use lib
"$ENV{HOME}/bin/src/fldb";
24 use lib
"$ENV{HOME}/bin/src/gpstools";
33 our $CMD = "../$CMDB";
47 $progname =~ s/^.*\/(.*?)$/$1/;
48 our $VERSION = '0.0.0';
50 my %descriptions = ();
52 Getopt
::Long
::Configure
('bundling');
55 'all|a' => \
$Opt{'all'},
56 'help|h' => \
$Opt{'help'},
57 'quiet|q+' => \
$Opt{'quiet'},
58 'todo|t' => \
$Opt{'todo'},
59 'verbose|v+' => \
$Opt{'verbose'},
60 'version' => \
$Opt{'version'},
62 ) || die("$progname: Option error. Use -h for help.\n");
64 $Opt{'verbose'} -= $Opt{'quiet'};
65 $Opt{'help'} && usage
(0);
66 if ($Opt{'version'}) {
77 diag
(sprintf('========== Executing %s v%s ==========',
78 $progname, $VERSION));
80 if ($Opt{'todo'} && !$Opt{'all'}) {
86 testcmd("$CMD command", # {{{
101 'Authen::SASL' => 'libauthen-sasl-perl',
104 'DBI' => 'libdbi-perl',
105 'Data::Dumper' => '',
106 'Date::Manip' => 'libdate-manip-perl',
107 'Devel::GDB' => 'libdevel-gdb-perl',
108 'Devel::NYTProf' => 'libdevel-nytprof-perl',
109 'Devel::ptkdb' => 'libdevel-ptkdb-perl',
110 'Digest::CRC' => 'libdigest-crc-perl',
111 'Digest::MD5' => 'libdigest-md5-file-perl',
112 'Digest::SHA' => 'libdigest-sha-perl',
115 'FLDBdebug' => '', # mine
116 'FLDBpg' => '', # mine
117 'FLDBsum' => '', # mine
118 'FLDButf' => '', # mine
120 'File::Basename' => '',
129 'GPSTdate' => '', # mine
130 'GPSTdebug' => '', # mine
131 'GPSTgeo' => '', # mine
132 'GPSTxml' => '', # mine
133 'Getopt::Long' => '',
135 'GraphViz' => 'libgraphviz-perl',
136 'HTML::Template' => 'libhtml-template-perl',
137 'HTML::TreeBuilder' => 'libxml-treebuilder-perl libhtml-treebuilder-xpath-perl',
138 'HTML::WikiConverter' => 'libhtml-wikiconverter-mediawiki-perl',
141 'Image::ExifTool' => 'libimage-exiftool-perl',
142 'JSON::XS' => 'libjson-xs-perl',
143 'MIME::Base64' => 'libmime-base64-urlsafe-perl',
144 'Math::Round' => 'libmath-round-perl',
145 'Module::Starter' => 'libmodule-starter-perl',
146 'Module::Starter::Plugin::CGIApp' => 'libmodule-starter-plugin-cgiapp-perl',
147 'Net::SMTP::SSL' => 'libnet-smtp-ssl-perl',
148 'Number::Bytes::Human' => 'libnumber-bytes-human-perl',
149 'OSSP::uuid' => 'libossp-uuid-perl',
151 'Perl::Critic' => 'libtest-perl-critic-perl',
153 'Term::ReadLine' => '',
154 'Term::ReadLine::Gnu' => 'libterm-readline-gnu-perl',
155 'Term::ReadLine::Perl' => 'libterm-readline-perl-perl',
157 'Test::Perl::Critic' => 'libtest-perl-critic-perl',
158 'Text::Diff' => 'libtext-diff-perl',
161 'XML::Parser' => 'libxml-parser-perl',
171 my $outfile = './install-modules';
174 for my $mod (sort keys %Modules) {
175 my $package = $Modules{$mod};
176 use_ok
($mod) || length($package) && push(@missing, $package);
178 -e
"nytprof.out" && ok
(unlink("nytprof.out"), "Remove nytprof.out");
180 if (scalar(@missing)) {
181 open(my $fp, '>', $outfile) || die("$progname: $outfile: Cannot create file: $!\n");
186 '# Created by perlmodules.t',
188 "sudo apt-get update\n",
191 for my $m (@missing) {
192 print($fp "sudo apt-get --assume-yes install $m\n");
194 ok
(close($fp), "Close $outfile");
195 ok
(chmod(0755, $outfile), "Make $outfile executable");
196 diag
("\nExecute $outfile to install missing modules.\n\n");
197 diag
("Contents of $outfile:\n==== BEGIN ====\n", file_data
($outfile), "==== END ====\n\n");
203 if ($Opt{'all'} || $Opt{'todo'}) {
204 diag
('Running TODO tests...'); # {{{
209 # Insert TODO tests here.
215 diag
('Testing finished.');
222 my ($Cmd, $Exp_stdout, $Exp_stderr, $Exp_retval, $Desc) = @_;
223 defined($descriptions{$Desc}) &&
224 BAIL_OUT
("testcmd(): '$Desc' description is used twice");
225 $descriptions{$Desc} = 1;
227 my $cmd_outp_str = $Opt{'verbose'} >= 1 ?
"\"$Cmd\" - " : '';
228 my $Txt = join('', $cmd_outp_str, defined($Desc) ?
$Desc : '');
229 my $TMP_STDERR = "$CMDB-stderr.tmp";
232 if (defined($Exp_stderr)) {
233 $stderr_cmd = " 2>$TMP_STDERR";
235 $retval &= is
(`$Cmd$stderr_cmd`, $Exp_stdout, "$Txt (stdout)");
237 if (defined($Exp_stderr)) {
238 $retval &= is
(file_data
($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
241 diag
("Warning: stderr not defined for '$Txt'");
243 $retval &= is
($ret_val >> 8, $Exp_retval, "$Txt (retval)");
251 my ($Cmd, $Exp_stdout, $Exp_stderr, $Exp_retval, $Desc) = @_;
252 defined($descriptions{$Desc}) &&
253 BAIL_OUT
("likecmd(): '$Desc' description is used twice");
254 $descriptions{$Desc} = 1;
256 my $cmd_outp_str = $Opt{'verbose'} >= 1 ?
"\"$Cmd\" - " : '';
257 my $Txt = join('', $cmd_outp_str, defined($Desc) ?
$Desc : '');
258 my $TMP_STDERR = "$CMDB-stderr.tmp";
261 if (defined($Exp_stderr)) {
262 $stderr_cmd = " 2>$TMP_STDERR";
264 $retval &= like
(`$Cmd$stderr_cmd`, $Exp_stdout, "$Txt (stdout)");
266 if (defined($Exp_stderr)) {
267 $retval &= like
(file_data
($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
270 diag
("Warning: stderr not defined for '$Txt'");
272 $retval &= is
($ret_val >> 8, $Exp_retval, "$Txt (retval)");
279 # Return file content as a string {{{
283 open(my $fp, '<', $File) or return undef;
292 # Print program version {{{
293 print("$progname $VERSION\n");
299 # Send the help message to stdout {{{
302 if ($Opt{'verbose'}) {
308 Usage: $progname [options]
310 Find missing Perl modules.
315 Run all tests, also TODOs.
319 Be more quiet. Can be repeated to increase silence.
321 Run only the TODO tests.
323 Increase level of verbosity. Can be repeated.
325 Print version information.
333 # Print a status message to stderr based on verbosity level {{{
334 my ($verbose_level, $Txt) = @_;
336 $verbose_level > $Opt{'verbose'} && return;
337 print(STDERR
"$progname: $Txt\n");
344 # This program is free software; you can redistribute it and/or modify
345 # it under the terms of the GNU General Public License as published by
346 # the Free Software Foundation; either version 2 of the License, or (at
347 # your option) any later version.
349 # This program is distributed in the hope that it will be useful, but
350 # WITHOUT ANY WARRANTY; without even the implied warranty of
351 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
352 # See the GNU General Public License for more details.
354 # You should have received a copy of the GNU General Public License
355 # along with this program.
356 # If not, see L<http://www.gnu.org/licenses/>.
358 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :