summaryrefslogtreecommitdiff
path: root/autoopts/test/cond.test
blob: 8767eda7a680b8b007dfcdde21e6a75b958932ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#! /bin/sh
#  -*- Mode: Shell-script -*-
# ----------------------------------------------------------------------
# cond.test     ---  test conditionally compiled option
#
# Time-stamp:        "2012-03-31 13:09:15 bkorb"
# Author:            Bruce Korb <bkorb@gnu.org>
##
##  This file is part of AutoOpts, a companion to AutoGen.
##  AutoOpts is free software.
##  AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
##
##  AutoOpts is available under any one of two licenses.  The license
##  in use must be one of these two and the choice is under the control
##  of the user of the license.
##
##   The GNU Lesser General Public License, version 3 or later
##      See the files "COPYING.lgplv3" and "COPYING.gplv3"
##
##   The Modified Berkeley Software Distribution License
##      See the file "COPYING.mbsd"
##
##  These files have the following md5sums:
##
##  43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3
##  06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3
##  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
#
# ----------------------------------------------------------------------

. ./defs

# # # # # # # # # # DEFINITIONS FILE # # # # # # # # #

echo "creating ${testname}.def in `pwd`"
testname="${testname}" test_main="${test_main}" \
argument="${argument}" long_opts="${long_opts}" \
${SHELLX} ${stdopts} option:'opt init' second=020 || \
    failure "Could not run stdopts.def"
cat >> ${testname}.def <<EOF
flag = {
  name  = condition;
  value = c;
  ifdef = COND;
  descrip = "cond test";
  arg-type = number;
  doc = mumble;
};

flag = {
  name  = interfere;
  value = I;
  descrip = "cond interference test";
  arg-type = number;
  doc = stumble;
};
EOF
echo ${AG_L} ${testname}.def
${AG_L} ${testname}.def || \
  failure AutoGen could not process

# # # # # # # # # # FIRST TEST # # # # # # # # #

compile "-?"
mv ${testname} ${testname}-1
echo creating ${testname}-1.help
clean_help > ${testname}-1.help <<'_EOF_'
test_cond - Test AutoOpts for cond
USAGE:  cond [ -<flag> [<val>] ]...
  Flg Arg Option-Name    Description
   -o Str option         The option option descrip
   -s Num second         The second option descrip
   -I Num interfere      cond interference test
   -? no  help           Display extended usage information and exit
   -! no  more-help      Extended usage information passed thru pager

_EOF_

cmp -s ${testname}-1.help ${testname}.help || \
  failure "TEST 1 FAILED${nl}`diff ${testname}-1.help ${testname}.help`"

./${testname}-1 -c 123 2>/dev/null && \
    failure "*DID* process -c option"

# # # # # # # # # # SECOND TEST # # # # # # # # #

INC="${INC} -DCOND=1"
compile "-?"
mv ${testname} ${testname}-2
clean_help > ${testname}-2.help <<'_EOF_'
test_cond - Test AutoOpts for cond
USAGE:  cond [ -<flag> [<val>] ]...
  Flg Arg Option-Name    Description
   -o Str option         The option option descrip
   -s Num second         The second option descrip
   -c Num condition      cond test
   -I Num interfere      cond interference test
   -? no  help           Display extended usage information and exit
   -! no  more-help      Extended usage information passed thru pager

_EOF_

cmp -s ${testname}-2.help ${testname}.help || \
  failure "TEST 2 FAILED${nl}`diff ${testname}-2.help ${testname}.help`"

# # # # # # # # # # THIRD TEST # # # # # # # # #

echo guard-option-names\; >> ${testname}.def
echo ${AG_L} ${testname}.def
${AG_L} ${testname}.def || failure AutoGen could not process

( cc_cmd=`echo ${cc_cmd} | \
  ${SED} "s/-DTEST_TEST/-DSECOND -DTEST_TEST/" `
  eval "$cc_cmd" 2>&1 ) \
  | ${SED} -n '/undefining SECOND due to option name conflict/p' \
    > ${testname}-cc.log

test -s ${testname}-cc.log || \
    failure "warning diffs:  'undefining SECOND' not found"

# # # # # # # # # # FOURTH TEST # # # # # # # # #

${SED} '/value = c/s/$/ deprecated;/' ${testname}.def > ${testname}.def4

echo ${AG_L} ${testname}.def4
${AG_L} ${testname}.def4 || \
  failure AutoGen could not process ${testname}.def4

compile "-?"
mv ${testname} ${testname}-4
cmp -s ${testname}-1.help ${testname}.help || \
  failure "TEST 4 FAILED${nl}`diff ${testname}-1.help ${testname}.help`"

./${testname}-4 -c 123 || \
    failure "could not process -c option"

# # # # # # # # # # FIFTH TEST # # # # # # # # #

${SED} '/deprecated/s/deprecated.*/arg-range = "0->1000";/' \
    ${testname}.def4 > ${testname}.def5

echo ${AG_L} ${testname}.def5
${AG_L} ${testname}.def5 || \
  failure AutoGen could not process ${testname}.def5

compile "-?"
mv ${testname} ${testname}-5
clean_help > ${testname}-5.help <<'_EOF_'
test_cond - Test AutoOpts for cond
USAGE:  cond [ -<flag> [<val>] ]...
  Flg Arg Option-Name    Description
   -o Str option         The option option descrip
   -s Num second         The second option descrip
   -c Num condition      cond test
				- It must be in the range:
				  0 to 1000
   -I Num interfere      cond interference test
   -? no  help           Display extended usage information and exit
   -! no  more-help      Extended usage information passed thru pager

_EOF_

cmp -s ${testname}-5.help ${testname}.help || \
  failure "TEST 5 FAILED${nl}`diff -u ${testname}-5.help ${testname}.help`"

# # # # # # # # # # SIXTH TEST # # # # # # # # #

INC=`echo ${INC} | sed 's/ -DCOND=1//'`
compile "-?"
mv ${testname} ${testname}-6
clean_help > ${testname}-6.help <<'_EOF_'
test_cond - Test AutoOpts for cond
USAGE:  cond [ -<flag> [<val>] ]...
  Flg Arg Option-Name    Description
   -o Str option         The option option descrip
   -s Num second         The second option descrip
   -I Num interfere      cond interference test
   -? no  help           Display extended usage information and exit
   -! no  more-help      Extended usage information passed thru pager

_EOF_

cmp -s ${testname}-6.help ${testname}.help || \
  failure "TEST 6 FAILED${nl}`diff -u ${testname}-6.help ${testname}.help`"

cleanup

## Local Variables:
## mode: shell-script
## indent-tabs-mode: nil
## sh-indentation: 2
## End:

# end of cond.test