3 #=======================================================================
5 # File ID: ccab1138-f924-11dd-9694-0001805bf4b1
6 # Test suite for addpoints(1).
9 # ©opyleft 2008– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
15 # push(@INC, "$ENV{'HOME'}/bin/STDlibdirDTS");
17 use Test
::More
qw{no_plan
};
27 our $CMD = "../../addpoints";
41 $progname =~ s/^.*\/(.*?)$/$1/;
44 my $id_date = $rcs_id;
45 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/;
47 push(@main::version_array
, $rcs_id);
49 my @cmdline_array = @ARGV;
51 Getopt
::Long
::Configure
("bundling");
54 "all|a" => \
$Opt{'all'},
55 "debug" => \
$Opt{'debug'},
56 "help|h" => \
$Opt{'help'},
57 "todo|t" => \
$Opt{'todo'},
58 "verbose|v+" => \
$Opt{'verbose'},
59 "version" => \
$Opt{'version'},
61 ) || die("$progname: Option error. Use -h for help.\n");
63 $Opt{'debug'} && ($Debug = 1);
64 $Opt{'help'} && usage
(0);
65 if ($Opt{'version'}) {
70 diag
(sprintf("========== Executing \"%s%s%s\" ==========",
72 scalar(@cmdline_array) ?
" " : "",
73 join(" ", @cmdline_array)));
75 if ($Opt{'todo'} && !$Opt{'all'}) {
81 testcmd("$CMD command", # {{{
93 diag
("Testing -h (--help) option...");
94 likecmd
("$CMD -h", # {{{
95 '/ Show this help\./',
97 "Option -h prints help screen",
101 ok
(`$CMD -h` !~ /\$Id: /s, "\"$CMD -h\" - No Id with only -h");
102 diag
("Testing -v (--verbose) option...");
103 likecmd
("$CMD -hv", # {{{
104 '/\$Id: .*? \$.* Show this help\./s',
106 "Option --version with -h returns Id string and help screen",
110 diag
("Testing --version option...");
111 likecmd
("$CMD --version", # {{{
114 "Option --version returns Id string",
122 if ($Opt{'all'} || $Opt{'todo'}) {
123 diag
("Running TODO tests..."); # {{{
128 # Insert TODO tests here.
134 diag
("Testing finished.");
138 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
140 my $deb_str = $Opt{'debug'} ?
" --debug" : "";
147 my $TMP_STDERR = "addpoints-stderr.tmp";
149 if (defined($Exp_stderr) && !length($deb_str)) {
150 $stderr_cmd = " 2>$TMP_STDERR";
152 is
(`$Cmd$deb_str$stderr_cmd`, $Exp_stdout, $Txt);
153 if (defined($Exp_stderr)) {
154 if (!length($deb_str)) {
155 is
(file_data
($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
159 diag
("Warning: stderr not defined for '$Txt'");
166 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
168 my $deb_str = $Opt{'debug'} ?
" --debug" : "";
175 my $TMP_STDERR = "addpoints-stderr.tmp";
177 if (defined($Exp_stderr) && !length($deb_str)) {
178 $stderr_cmd = " 2>$TMP_STDERR";
180 like
(`$Cmd$deb_str$stderr_cmd`, "$Exp_stdout", $Txt);
181 if (defined($Exp_stderr)) {
182 if (!length($deb_str)) {
183 like
(file_data
($TMP_STDERR), "$Exp_stderr", "$Txt (stderr)");
187 diag
("Warning: stderr not defined for '$Txt'");
193 # Return file content as a string {{{
196 if (open(FP
, "<", $File)) {
197 $Txt = join("", <FP
>);
207 # Print program version {{{
208 for (@main::version_array
) {
215 # Send the help message to stdout {{{
218 if ($Opt{'verbose'}) {
224 Usage: $progname [options] [file [files [...]]]
226 Contains tests for the addpoints(1) program.
231 Run all tests, also TODOs.
235 Run only the TODO tests.
237 Increase level of verbosity. Can be repeated.
239 Print version information.
241 Print debugging messages.
249 # Print a status message to stderr based on verbosity level {{{
250 my ($verbose_level, $Txt) = @_;
252 if ($Opt{'verbose'} >= $verbose_level) {
253 print(STDERR
"$progname: $Txt\n");
260 # Plain Old Documentation (POD) {{{
274 addpoints.t [options] [file [files [...]]]
278 Contains tests for the addpoints(1) program.
284 =item B<-a>, B<--all>
286 Run all tests, also TODOs.
288 =item B<-h>, B<--help>
290 Print a brief help summary.
292 =item B<-t>, B<--todo>
294 Run only the TODO tests.
296 =item B<-v>, B<--verbose>
298 Increase level of verbosity. Can be repeated.
302 Print version information.
306 Print debugging messages.
312 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
316 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
317 This is free software; see the file F<COPYING> for legalese stuff.
321 This program is free software; you can redistribute it and/or modify it
322 under the terms of the GNU General Public License as published by the
323 Free Software Foundation; either version 2 of the License, or (at your
324 option) any later version.
326 This program is distributed in the hope that it will be useful, but
327 WITHOUT ANY WARRANTY; without even the implied warranty of
328 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
329 See the GNU General Public License for more details.
331 You should have received a copy of the GNU General Public License along
332 with this program; if not, write to the Free Software Foundation, Inc.,
333 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
341 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :