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 #=======================================================================
15 # push(@INC, "$ENV{'HOME'}/bin/STDlibdirDTS");
16 use Test
::More
qw{no_plan
};
26 our $CMD = "../csv2gpx";
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 ok
(`$CMD -h` !~ /^\n\S+ v\d\.\d\d\n/s, "\"$CMD -h\" - No Id with only -h");
93 diag
("Testing -v (--verbose) option...");
94 likecmd
("$CMD -hv", # {{{
95 '/^\n\S+ v\d\.\d\d\n/s',
97 "Option --version with -h returns version number and help screen",
101 diag
("Testing --version option...");
102 likecmd
("$CMD --version", # {{{
103 '/^\S+ v\d\.\d\d\n/',
105 "Option --version returns version number",
113 if ($Opt{'all'} || $Opt{'todo'}) {
114 diag
("Running TODO tests..."); # {{{
119 # Insert TODO tests here.
125 diag
("Testing finished.");
129 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
131 my $deb_str = $Opt{'debug'} ?
" --debug" : "";
138 my $TMP_STDERR = "csv2gpx-stderr.tmp";
140 if (defined($Exp_stderr) && !length($deb_str)) {
141 $stderr_cmd = " 2>$TMP_STDERR";
143 is
(`$Cmd$deb_str$stderr_cmd`, $Exp_stdout, $Txt);
144 if (defined($Exp_stderr)) {
145 if (!length($deb_str)) {
146 is
(file_data
($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
150 diag
("Warning: stderr not defined for '$Txt'");
157 my ($Cmd, $Exp_stdout, $Exp_stderr, $Desc) = @_;
159 my $deb_str = $Opt{'debug'} ?
" --debug" : "";
166 my $TMP_STDERR = "csv2gpx-stderr.tmp";
168 if (defined($Exp_stderr) && !length($deb_str)) {
169 $stderr_cmd = " 2>$TMP_STDERR";
171 like
(`$Cmd$deb_str$stderr_cmd`, "$Exp_stdout", $Txt);
172 if (defined($Exp_stderr)) {
173 if (!length($deb_str)) {
174 like
(file_data
($TMP_STDERR), "$Exp_stderr", "$Txt (stderr)");
178 diag
("Warning: stderr not defined for '$Txt'");
184 # Return file content as a string {{{
187 if (open(FP
, "<", $File)) {
188 $Txt = join("", <FP
>);
198 # Print program version {{{
199 print("$progname v$VERSION\n");
204 # Send the help message to stdout {{{
207 if ($Opt{'verbose'}) {
213 Usage: $progname [options] [file [files [...]]]
215 Contains tests for the csv2gpx(1) program.
220 Run all tests, also TODOs.
224 Run only the TODO tests.
226 Increase level of verbosity. Can be repeated.
228 Print version information.
230 Print debugging messages.
238 # Print a status message to stderr based on verbosity level {{{
239 my ($verbose_level, $Txt) = @_;
241 if ($Opt{'verbose'} >= $verbose_level) {
242 print(STDERR
"$progname: $Txt\n");
249 # Plain Old Documentation (POD) {{{
259 csv2gpx.t [options] [file [files [...]]]
263 Contains tests for the csv2gpx(1) program.
269 =item B<-a>, B<--all>
271 Run all tests, also TODOs.
273 =item B<-h>, B<--help>
275 Print a brief help summary.
277 =item B<-t>, B<--todo>
279 Run only the TODO tests.
281 =item B<-v>, B<--verbose>
283 Increase level of verbosity. Can be repeated.
287 Print version information.
291 Print debugging messages.
297 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
301 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
302 This is free software; see the file F<COPYING> for legalese stuff.
306 This program is free software: you can redistribute it and/or modify it
307 under the terms of the GNU General Public License as published by the
308 Free Software Foundation, either version 3 of the License, or (at your
309 option) any later version.
311 This program is distributed in the hope that it will be useful, but
312 WITHOUT ANY WARRANTY; without even the implied warranty of
313 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
314 See the GNU General Public License for more details.
316 You should have received a copy of the GNU General Public License along
318 If not, see L<http://www.gnu.org/licenses/>.
326 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :