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 'Net::SMTP::SSL' => 'libnet-smtp-ssl-perl',
146 'Number::Bytes::Human' => 'libnumber-bytes-human-perl',
147 'OSSP::uuid' => 'libossp-uuid-perl',
149 'Perl::Critic' => 'libtest-perl-critic-perl',
151 'Term::ReadLine' => '',
152 'Term::ReadLine::Gnu' => 'libterm-readline-gnu-perl',
153 'Term::ReadLine::Perl' => 'libterm-readline-perl-perl',
155 'Test::Perl::Critic' => 'libtest-perl-critic-perl',
156 'Text::Diff' => 'libtext-diff-perl',
159 'XML::Parser' => 'libxml-parser-perl',
169 my $outfile = './install-modules';
172 for my $mod (sort keys %Modules) {
173 my $package = $Modules{$mod};
174 use_ok
($mod) || length($package) && push(@missing, $package);
176 -e
"nytprof.out" && ok
(unlink("nytprof.out"), "Remove nytprof.out");
178 if (scalar(@missing)) {
179 open(my $fp, '>', $outfile) || die("$progname: $outfile: Cannot create file: $!\n");
184 '# Created by perlmodules.t',
186 "sudo apt-get update\n",
189 for my $m (@missing) {
190 print($fp "sudo apt-get --assume-yes install $m\n");
192 ok
(close($fp), "Close $outfile");
193 ok
(chmod(0755, $outfile), "Make $outfile executable");
194 diag
("\nExecute $outfile to install missing modules.\n\n");
195 diag
("Contents of $outfile:\n==== BEGIN ====\n", file_data
($outfile), "==== END ====\n\n");
201 if ($Opt{'all'} || $Opt{'todo'}) {
202 diag
('Running TODO tests...'); # {{{
207 # Insert TODO tests here.
213 diag
('Testing finished.');
220 my ($Cmd, $Exp_stdout, $Exp_stderr, $Exp_retval, $Desc) = @_;
221 defined($descriptions{$Desc}) &&
222 BAIL_OUT
("testcmd(): '$Desc' description is used twice");
223 $descriptions{$Desc} = 1;
225 my $cmd_outp_str = $Opt{'verbose'} >= 1 ?
"\"$Cmd\" - " : '';
226 my $Txt = join('', $cmd_outp_str, defined($Desc) ?
$Desc : '');
227 my $TMP_STDERR = "$CMDB-stderr.tmp";
230 if (defined($Exp_stderr)) {
231 $stderr_cmd = " 2>$TMP_STDERR";
233 $retval &= is
(`$Cmd$stderr_cmd`, $Exp_stdout, "$Txt (stdout)");
235 if (defined($Exp_stderr)) {
236 $retval &= is
(file_data
($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
239 diag
("Warning: stderr not defined for '$Txt'");
241 $retval &= is
($ret_val >> 8, $Exp_retval, "$Txt (retval)");
249 my ($Cmd, $Exp_stdout, $Exp_stderr, $Exp_retval, $Desc) = @_;
250 defined($descriptions{$Desc}) &&
251 BAIL_OUT
("likecmd(): '$Desc' description is used twice");
252 $descriptions{$Desc} = 1;
254 my $cmd_outp_str = $Opt{'verbose'} >= 1 ?
"\"$Cmd\" - " : '';
255 my $Txt = join('', $cmd_outp_str, defined($Desc) ?
$Desc : '');
256 my $TMP_STDERR = "$CMDB-stderr.tmp";
259 if (defined($Exp_stderr)) {
260 $stderr_cmd = " 2>$TMP_STDERR";
262 $retval &= like
(`$Cmd$stderr_cmd`, $Exp_stdout, "$Txt (stdout)");
264 if (defined($Exp_stderr)) {
265 $retval &= like
(file_data
($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
268 diag
("Warning: stderr not defined for '$Txt'");
270 $retval &= is
($ret_val >> 8, $Exp_retval, "$Txt (retval)");
277 # Return file content as a string {{{
281 open(my $fp, '<', $File) or return undef;
290 # Print program version {{{
291 print("$progname $VERSION\n");
297 # Send the help message to stdout {{{
300 if ($Opt{'verbose'}) {
306 Usage: $progname [options]
308 Find missing Perl modules.
313 Run all tests, also TODOs.
317 Be more quiet. Can be repeated to increase silence.
319 Run only the TODO tests.
321 Increase level of verbosity. Can be repeated.
323 Print version information.
331 # Print a status message to stderr based on verbosity level {{{
332 my ($verbose_level, $Txt) = @_;
334 $verbose_level > $Opt{'verbose'} && return;
335 print(STDERR
"$progname: $Txt\n");
342 # This program is free software; you can redistribute it and/or modify
343 # it under the terms of the GNU General Public License as published by
344 # the Free Software Foundation; either version 2 of the License, or (at
345 # your option) any later version.
347 # This program is distributed in the hope that it will be useful, but
348 # WITHOUT ANY WARRANTY; without even the implied warranty of
349 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
350 # See the GNU General Public License for more details.
352 # You should have received a copy of the GNU General Public License
353 # along with this program.
354 # If not, see L<http://www.gnu.org/licenses/>.
356 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :