3 #=======================================================================
5 # File ID: d4031198-f987-11dd-9f3b-000475e441b9
6 # Test suite for csv2gpx(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 #=======================================================================
18 # push(@INC, "$ENV{'HOME'}/bin/STDlibdirDTS");
19 use Test
::More
qw{no_plan
};
28 our $CMD = "../csv2gpx";
42 $progname =~ s/^.*\/(.*?)$/$1/;
43 our $VERSION = "0.00";
45 Getopt
::Long
::Configure
("bundling");
48 "all|a" => \
$Opt{'all'},
49 "debug" => \
$Opt{'debug'},
50 "help|h" => \
$Opt{'help'},
51 "todo|t" => \
$Opt{'todo'},
52 "verbose|v+" => \
$Opt{'verbose'},
53 "version" => \
$Opt{'version'},
55 ) || die("$progname: Option error. Use -h for help.\n");
57 $Opt{'debug'} && ($Debug = 1);
58 $Opt{'help'} && usage
(0);
59 if ($Opt{'version'}) {
64 diag
(sprintf("========== Executing %s v%s ==========",
68 if ($Opt{'todo'} && !$Opt{'all'}) {
74 testcmd("$CMD command", # {{{
86 diag
("Testing -h (--help) option...");
87 likecmd
("$CMD -h", # {{{
88 '/ Show this help\./',
90 "Option -h prints help screen",
94 diag
("Testing -v (--verbose) option...");
95 likecmd
("$CMD -hv", # {{{
96 '/^\n\S+ v\d\.\d\d\n/s',
98 "Option --version with -h returns version number and help screen",
102 diag
("Testing --version option...");
103 likecmd
("$CMD --version", # {{{
104 '/^\S+ v\d\.\d\d\n/',
106 "Option --version returns version number",
114 if ($Opt{'all'} || $Opt{'todo'}) {
115 diag
("Running TODO tests..."); # {{{
120 # Insert TODO tests here.
126 diag
("Testing finished.");
130 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
132 my $deb_str = $Opt{'debug'} ?
" --debug" : "";
139 my $TMP_STDERR = "csv2gpx-stderr.tmp";
141 if (defined($Exp_stderr) && !length($deb_str)) {
142 $stderr_cmd = " 2>$TMP_STDERR";
144 is
(`$Cmd$deb_str$stderr_cmd`, $Exp_stdout, $Txt);
145 if (defined($Exp_stderr)) {
146 if (!length($deb_str)) {
147 is
(file_data
($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
151 diag
("Warning: stderr not defined for '$Txt'");
158 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
160 my $deb_str = $Opt{'debug'} ?
" --debug" : "";
167 my $TMP_STDERR = "csv2gpx-stderr.tmp";
169 if (defined($Exp_stderr) && !length($deb_str)) {
170 $stderr_cmd = " 2>$TMP_STDERR";
172 like
(`$Cmd$deb_str$stderr_cmd`, "$Exp_stdout", $Txt);
173 if (defined($Exp_stderr)) {
174 if (!length($deb_str)) {
175 like
(file_data
($TMP_STDERR), "$Exp_stderr", "$Txt (stderr)");
179 diag
("Warning: stderr not defined for '$Txt'");
185 # Return file content as a string {{{
188 if (open(my $fp, "<", $File)) {
189 $Txt = join("", <$fp>);
199 # Print program version {{{
200 print("$progname v$VERSION\n");
205 # Send the help message to stdout {{{
208 if ($Opt{'verbose'}) {
214 Usage: $progname [options] [file [files [...]]]
216 Contains tests for the csv2gpx(1) program.
221 Run all tests, also TODOs.
225 Run only the TODO tests.
227 Increase level of verbosity. Can be repeated.
229 Print version information.
231 Print debugging messages.
239 # Print a status message to stderr based on verbosity level {{{
240 my ($verbose_level, $Txt) = @_;
242 if ($Opt{'verbose'} >= $verbose_level) {
243 print(STDERR
"$progname: $Txt\n");
250 # Plain Old Documentation (POD) {{{
260 csv2gpx.t [options] [file [files [...]]]
264 Contains tests for the csv2gpx(1) program.
270 =item B<-a>, B<--all>
272 Run all tests, also TODOs.
274 =item B<-h>, B<--help>
276 Print a brief help summary.
278 =item B<-t>, B<--todo>
280 Run only the TODO tests.
282 =item B<-v>, B<--verbose>
284 Increase level of verbosity. Can be repeated.
288 Print version information.
292 Print debugging messages.
298 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
302 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
303 This is free software; see the file F<COPYING> for legalese stuff.
307 This program is free software: you can redistribute it and/or modify it
308 under the terms of the GNU General Public License as published by the
309 Free Software Foundation, either version 3 of the License, or (at your
310 option) any later version.
312 This program is distributed in the hope that it will be useful, but
313 WITHOUT ANY WARRANTY; without even the implied warranty of
314 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
315 See the GNU General Public License for more details.
317 You should have received a copy of the GNU General Public License along
319 If not, see L<http://www.gnu.org/licenses/>.
327 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :