Avoid a test failure on mingw.
[pspp] / tests / test-argp-2.sh
1 #! /bin/sh
2 # Test suite for argp.
3 # Copyright (C) 2006-2007 Free Software Foundation, Inc.
4 # This file is part of the GNUlib Library.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19
20 TMP=argp.$$
21
22 unset ARGP_HELP_FMT
23 ERR=0
24
25 func_compare() {
26 # If argp was compiled without base_name, it will display full program name.
27 # If run on mingw, it will display the program name with a .exe suffix.
28   sed '1{
29          s,: [^ ]*/test-argp,: test-argp,
30          s,: test-argp\.exe,: test-argp,
31         }' | diff -c $TMP -
32 }  
33
34 ####
35 # Test --usage output
36 cat > $TMP <<EOT
37 Usage: test-argp [-tvCSOlp?V] [-f FILE] [-o[ARG]] [--test] [--file=FILE]
38             [--input=FILE] [--verbose] [--cantiga] [--sonet] [--option]
39             [--optional[=ARG]] [--limerick] [--poem] [--help] [--usage]
40             [--version] ARGS...
41 EOT
42
43 ./test-argp --usage | func_compare || ERR=1
44
45 ####
46 # Test working usage-indent format
47
48 cat > $TMP <<EOT
49 Usage: test-argp [-tvCSOlp?V] [-f FILE] [-o[ARG]] [--test] [--file=FILE]
50 [--input=FILE] [--verbose] [--cantiga] [--sonet] [--option] [--optional[=ARG]]
51 [--limerick] [--poem] [--help] [--usage] [--version] ARGS...
52 EOT
53
54 ARGP_HELP_FMT='usage-indent=0' ./test-argp --usage | func_compare || ERR=1
55
56 ####
57 # Test --help output
58 cat >$TMP <<EOT
59 Usage: test-argp [OPTION...] ARGS...
60 documentation string
61
62  Main options
63   -t, --test
64
65  Option Group 1
66   -f, --file=FILE, --input=FILE   Option with a mandatory argument
67   -v, --verbose              Simple option without arguments
68
69  Option Group 1.1
70   -C, --cantiga              create a cantiga
71   -S, --sonet                create a sonet
72
73  Option Group 2
74   -O, --option               An option
75
76   -o, --optional[=ARG]       Option with an optional argument. ARG is one of
77                              the following:
78
79   many                       many units
80   one                        one unit
81   two                        two units
82
83  Option Group 2.1
84   -l, --limerick             create a limerick
85   -p, --poem                 create a poem
86
87   -?, --help                 give this help list
88       --usage                give a short usage message
89   -V, --version              print program version
90
91 Mandatory or optional arguments to long options are also mandatory or optional
92 for any corresponding short options.
93
94 Report bugs to <>.
95 EOT
96
97 ./test-argp --help | func_compare || ERR=1
98
99 ####
100 # Test ambiguous option handling
101
102 ./test-argp --optio 2>/dev/null && ERR=1
103
104 ####
105 # Run built-in tests
106 ./test-argp || ERR=1
107
108 rm $TMP
109
110 exit $ERR