3 #=======================================================================
4 # tests/addpoints/addpoints.t
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 3 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
15 # push(@INC, "$ENV{'HOME'}/bin/STDlibdirDTS");
16 use Test
::More
qw{no_plan
};
26 our $CMD = "../../addpoints";
40 $progname =~ s/^.*\/(.*?)$/$1/;
41 our $VERSION = "0.00";
43 Getopt
::Long
::Configure
("bundling");
46 "all|a" => \
$Opt{'all'},
47 "debug" => \
$Opt{'debug'},
48 "help|h" => \
$Opt{'help'},
49 "todo|t" => \
$Opt{'todo'},
50 "verbose|v+" => \
$Opt{'verbose'},
51 "version" => \
$Opt{'version'},
53 ) || die("$progname: Option error. Use -h for help.\n");
55 $Opt{'debug'} && ($Debug = 1);
56 $Opt{'help'} && usage
(0);
57 if ($Opt{'version'}) {
62 diag
(sprintf("========== Executing %s v%s ==========",
66 if ($Opt{'todo'} && !$Opt{'all'}) {
72 testcmd("$CMD command", # {{{
84 diag
("Testing -h (--help) option...");
85 likecmd
("$CMD -h", # {{{
86 '/ Show this help\./',
88 "Option -h prints help screen",
92 diag
("Testing -v (--verbose) option...");
93 likecmd
("$CMD -hv", # {{{
94 '/^\n\S+ v\d\.\d\d\n/s',
96 "Option --version with -h returns version number and help screen",
100 diag
("Testing --version option...");
101 likecmd
("$CMD --version", # {{{
102 '/^\S+ v\d\.\d\d\n/',
104 "Option --version returns version number",
112 if ($Opt{'all'} || $Opt{'todo'}) {
113 diag
("Running TODO tests..."); # {{{
118 # Insert TODO tests here.
124 diag
("Testing finished.");
128 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
130 my $deb_str = $Opt{'debug'} ?
" --debug" : "";
137 my $TMP_STDERR = "addpoints-stderr.tmp";
139 if (defined($Exp_stderr) && !length($deb_str)) {
140 $stderr_cmd = " 2>$TMP_STDERR";
142 is
(`$Cmd$deb_str$stderr_cmd`, $Exp_stdout, $Txt);
143 if (defined($Exp_stderr)) {
144 if (!length($deb_str)) {
145 is
(file_data
($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
149 diag
("Warning: stderr not defined for '$Txt'");
156 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
158 my $deb_str = $Opt{'debug'} ?
" --debug" : "";
165 my $TMP_STDERR = "addpoints-stderr.tmp";
167 if (defined($Exp_stderr) && !length($deb_str)) {
168 $stderr_cmd = " 2>$TMP_STDERR";
170 like
(`$Cmd$deb_str$stderr_cmd`, "$Exp_stdout", $Txt);
171 if (defined($Exp_stderr)) {
172 if (!length($deb_str)) {
173 like
(file_data
($TMP_STDERR), "$Exp_stderr", "$Txt (stderr)");
177 diag
("Warning: stderr not defined for '$Txt'");
183 # Return file content as a string {{{
186 if (open(my $fp, "<", $File)) {
187 $Txt = join("", <$fp>);
197 # Print program version {{{
198 print("$progname v$VERSION\n");
203 # Send the help message to stdout {{{
206 if ($Opt{'verbose'}) {
212 Usage: $progname [options] [file [files [...]]]
214 Contains tests for the addpoints(1) program.
219 Run all tests, also TODOs.
223 Run only the TODO tests.
225 Increase level of verbosity. Can be repeated.
227 Print version information.
229 Print debugging messages.
237 # Print a status message to stderr based on verbosity level {{{
238 my ($verbose_level, $Txt) = @_;
240 if ($Opt{'verbose'} >= $verbose_level) {
241 print(STDERR
"$progname: $Txt\n");
248 # Plain Old Documentation (POD) {{{
258 addpoints.t [options] [file [files [...]]]
262 Contains tests for the addpoints(1) program.
268 =item B<-a>, B<--all>
270 Run all tests, also TODOs.
272 =item B<-h>, B<--help>
274 Print a brief help summary.
276 =item B<-t>, B<--todo>
278 Run only the TODO tests.
280 =item B<-v>, B<--verbose>
282 Increase level of verbosity. Can be repeated.
286 Print version information.
290 Print debugging messages.
296 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
300 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
301 This is free software; see the file F<COPYING> for legalese stuff.
305 This program is free software: you can redistribute it and/or modify it
306 under the terms of the GNU General Public License as published by the
307 Free Software Foundation, either version 3 of the License, or (at your
308 option) any later version.
310 This program is distributed in the hope that it will be useful, but
311 WITHOUT ANY WARRANTY; without even the implied warranty of
312 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
313 See the GNU General Public License for more details.
315 You should have received a copy of the GNU General Public License along
317 If not, see L<http://www.gnu.org/licenses/>.
325 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :