1 | # -*- Autotest -*-
|
---|
2 |
|
---|
3 | AT_BANNER([M4sh.])
|
---|
4 |
|
---|
5 | # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
|
---|
6 | # Foundation, Inc.
|
---|
7 | #
|
---|
8 | # This program is free software; you can redistribute it and/or modify
|
---|
9 | # it under the terms of the GNU General Public License as published by
|
---|
10 | # the Free Software Foundation; either version 2, or (at your option)
|
---|
11 | # any later version.
|
---|
12 | #
|
---|
13 | # This program is distributed in the hope that it will be useful,
|
---|
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | # GNU General Public License for more details.
|
---|
17 | #
|
---|
18 | # You should have received a copy of the GNU General Public License
|
---|
19 | # along with this program; if not, write to the Free Software
|
---|
20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
---|
21 | # 02110-1301, USA.
|
---|
22 |
|
---|
23 | ## ---------------- ##
|
---|
24 | ## LINENO support. ##
|
---|
25 | ## ---------------- ##
|
---|
26 |
|
---|
27 | AT_SETUP([LINENO])
|
---|
28 |
|
---|
29 | # We cannot unset LINENO with Zsh, yet this test case relies on
|
---|
30 | # unsetting LINENO to compare its result when (i) LINENO is supported
|
---|
31 | # and when (ii) it is not.
|
---|
32 | # So just skip if the shell is ZSH.
|
---|
33 | AT_CHECK([test -n "${ZSH_VERSION+set}" && exit 77], ignore)
|
---|
34 |
|
---|
35 | # AT_DATA_LINENO(FILE-NAME,
|
---|
36 | # UNSET-LINENO = true | false, COUNTER, COUNTER-RE)
|
---|
37 | # ----------------------------------------------------------------
|
---|
38 | # Produce the FILE-NAME M4sh script which uses the COUNTER LINENO or
|
---|
39 | # _oline_, which we can recognized via COUNTER-RE. Unset LINENO is
|
---|
40 | # UNSET-LINENO.
|
---|
41 | #
|
---|
42 | # Use COUNTER, COUNTER-RE = [__LINENO__], [LINENO]
|
---|
43 | # or = [__OLINE__], [_oline__]
|
---|
44 | #
|
---|
45 | # instead of the obvious $LINENO and __oline__, because they would
|
---|
46 | # be replaced in the test suite itself, even before creating these
|
---|
47 | # scripts. For the same reason, grep for LINENO and _oline__ (sic).
|
---|
48 | #
|
---|
49 | # UNSET-LINENO is a shell condition to make sure the scripts have the
|
---|
50 | # same number of lines in the output, so that their outputs be identical.
|
---|
51 | m4_define([AT_DATA_LINENO],
|
---|
52 | [AT_DATA([$1.tas],
|
---|
53 | [[AS@&t@_INIT
|
---|
54 | if $2; then
|
---|
55 | AS@&t@_UNSET([LINENO])
|
---|
56 | fi
|
---|
57 | _AS@&t@_PREPARE
|
---|
58 | echo "Line: $3"
|
---|
59 | grep 'Line: .*$4' $[0] >/dev/null ||
|
---|
60 | AS@&t@_ERROR([cannot find original script])
|
---|
61 | exit 0
|
---|
62 | ]])
|
---|
63 | # If occurrences of $LINENO or __oline__ were wanted, create them.
|
---|
64 | sed 's/__LINENO__/$''LINENO/g;s/__OLINE__/__''oline__/g' $1.tas >$1.as
|
---|
65 | AT_CHECK([autom4te -l m4sh $1.as -o $1])
|
---|
66 | ])# AT_DATA_LINENO
|
---|
67 |
|
---|
68 | # `_oline_', once processed and ran, produces our reference.
|
---|
69 | # We check that we find ourselves by looking at a string which is
|
---|
70 | # available only in the original script: `_oline_'.
|
---|
71 | AT_DATA_LINENO([reference], [false], [__OLINE__], [_oline__])
|
---|
72 | AT_CHECK([./reference], 0, [stdout])
|
---|
73 |
|
---|
74 | # The reference:
|
---|
75 | mv stdout expout
|
---|
76 |
|
---|
77 | # Now using a maybe-functioning LINENO, with different call conventions.
|
---|
78 | # Be sure to be out of the PATH.
|
---|
79 | AT_CHECK([mkdir test || exit 77])
|
---|
80 |
|
---|
81 | AT_DATA_LINENO([test/test-1], [false], [__LINENO__], [LINENO])
|
---|
82 | AT_CHECK([./test/test-1], 0, [expout])
|
---|
83 | AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-1)],
|
---|
84 | 0, [expout])
|
---|
85 | AT_CHECK([sh ./test/test-1], 0, [expout])
|
---|
86 |
|
---|
87 | # Now using a disabled LINENO, with different call conventions.
|
---|
88 | AT_DATA_LINENO([test/test-2], [true], [__LINENO__], [LINENO])
|
---|
89 | AT_CHECK([./test/test-2], 0, [expout])
|
---|
90 | AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-2)],
|
---|
91 | 0, [expout])
|
---|
92 | AT_CHECK([sh ./test/test-2], 0, [expout])
|
---|
93 |
|
---|
94 | AT_CLEANUP
|
---|
95 |
|
---|
96 |
|
---|
97 |
|
---|
98 | ## ------------ ##
|
---|
99 | ## AS_DIRNAME. ##
|
---|
100 | ## ------------ ##
|
---|
101 |
|
---|
102 | # Build nested dirs.
|
---|
103 | AT_SETUP([AS@&t@_DIRNAME])
|
---|
104 |
|
---|
105 | AT_DATA_M4SH([script.as],
|
---|
106 | [[AS_INIT
|
---|
107 |
|
---|
108 | # The EXPR variant is allowed to fail if `expr' was considered as too
|
---|
109 | # weak for us, in which case `as_expr=false'.
|
---|
110 | m4_define([DIRNAME_TEST],
|
---|
111 | [dir=`AS_DIRNAME([$1])`
|
---|
112 | test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
|
---|
113 | echo "dirname($1) = $dir instead of $2" >&2
|
---|
114 |
|
---|
115 | if test "$as_expr" != false; then
|
---|
116 | dir=`_AS_DIRNAME_EXPR([$1])`
|
---|
117 | test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
|
---|
118 | echo "dirname_expr($1) = $dir instead of $2" >&2
|
---|
119 | fi
|
---|
120 |
|
---|
121 | dir=`_AS_DIRNAME_SED([$1])`
|
---|
122 | test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
|
---|
123 | echo "dirname_sed($1) = $dir instead of $2" >&2])
|
---|
124 |
|
---|
125 | DIRNAME_TEST([/], [/])
|
---|
126 | DIRNAME_TEST([//], [//], [/])
|
---|
127 | DIRNAME_TEST([///], [/])
|
---|
128 | DIRNAME_TEST([//1], [//], [/])
|
---|
129 | DIRNAME_TEST([/1], [/])
|
---|
130 | DIRNAME_TEST([./1], [.])
|
---|
131 | DIRNAME_TEST([../../2], [../..])
|
---|
132 | DIRNAME_TEST([//1/], [//], [/])
|
---|
133 | DIRNAME_TEST([/1/], [/])
|
---|
134 | DIRNAME_TEST([./1/], [.])
|
---|
135 | DIRNAME_TEST([../../2], [../..])
|
---|
136 | DIRNAME_TEST([//1/3], [//1])
|
---|
137 | DIRNAME_TEST([/1/3], [/1])
|
---|
138 | DIRNAME_TEST([./1/3], [./1])
|
---|
139 | DIRNAME_TEST([../../2/3], [../../2])
|
---|
140 | DIRNAME_TEST([//1/3///], [//1])
|
---|
141 | DIRNAME_TEST([/1/3///], [/1])
|
---|
142 | DIRNAME_TEST([./1/3///], [./1])
|
---|
143 | DIRNAME_TEST([../../2/3///], [../../2])
|
---|
144 | DIRNAME_TEST([//1//3/], [//1])
|
---|
145 | DIRNAME_TEST([/1//3/], [/1])
|
---|
146 | DIRNAME_TEST([./1//3/], [./1])
|
---|
147 | DIRNAME_TEST([../../2//3/], [../../2])
|
---|
148 | AS_EXIT(0)
|
---|
149 | ]])
|
---|
150 |
|
---|
151 | AT_CHECK_M4SH
|
---|
152 | AT_CHECK([./script])
|
---|
153 |
|
---|
154 | AT_CLEANUP
|
---|
155 |
|
---|
156 |
|
---|
157 |
|
---|
158 | ## ------------- ##
|
---|
159 | ## AS_BASENAME. ##
|
---|
160 | ## ------------- ##
|
---|
161 |
|
---|
162 | # Build nested dirs.
|
---|
163 | AT_SETUP([AS@&t@_BASENAME])
|
---|
164 |
|
---|
165 | AT_DATA_M4SH([script.as],
|
---|
166 | [[AS_INIT
|
---|
167 |
|
---|
168 | m4_define([BASENAME_TEST],
|
---|
169 | [base=`AS_BASENAME([$1])`
|
---|
170 | test "$base" = "$2" ||
|
---|
171 | echo "basename($1) = $base instead of $2" >&2
|
---|
172 |
|
---|
173 | base=`_AS_BASENAME_SED([$1])`
|
---|
174 | test "$base" = "$2" ||
|
---|
175 | echo "basename_sed($1) = $base instead of $2" >&2])
|
---|
176 |
|
---|
177 | BASENAME_TEST([//1], [1])
|
---|
178 | BASENAME_TEST([/1], [1])
|
---|
179 | BASENAME_TEST([./1], [1])
|
---|
180 | BASENAME_TEST([../../2], [2])
|
---|
181 | BASENAME_TEST([//1/], [1])
|
---|
182 | BASENAME_TEST([/1/], [1])
|
---|
183 | BASENAME_TEST([./1/], [1])
|
---|
184 | BASENAME_TEST([../../2], [2])
|
---|
185 | BASENAME_TEST([//1/3], [3])
|
---|
186 | BASENAME_TEST([/1/3], [3])
|
---|
187 | BASENAME_TEST([./1/3], [3])
|
---|
188 | BASENAME_TEST([../../2/3], [3])
|
---|
189 | BASENAME_TEST([//1/3///], [3])
|
---|
190 | BASENAME_TEST([/1/3///], [3])
|
---|
191 | BASENAME_TEST([./1/3///], [3])
|
---|
192 | BASENAME_TEST([../../2/3///], [3])
|
---|
193 | BASENAME_TEST([//1//3/], [3])
|
---|
194 | BASENAME_TEST([/1//3/], [3])
|
---|
195 | BASENAME_TEST([./1//3/], [3])
|
---|
196 | BASENAME_TEST([a.c], [a.c])
|
---|
197 | BASENAME_TEST([a.c/], [a.c])
|
---|
198 | BASENAME_TEST([/a.c/], [a.c])
|
---|
199 | BASENAME_TEST([/1/a.c], [a.c])
|
---|
200 | BASENAME_TEST([/1/a.c/], [a.c])
|
---|
201 | BASENAME_TEST([/1/../a.c], [a.c])
|
---|
202 | BASENAME_TEST([/1/../a.c/], [a.c])
|
---|
203 | BASENAME_TEST([./1/a.c], [a.c])
|
---|
204 | BASENAME_TEST([./1/a.c/], [a.c])
|
---|
205 | AS_EXIT(0)
|
---|
206 | ]])
|
---|
207 |
|
---|
208 | AT_CHECK_M4SH
|
---|
209 | AT_CHECK([./script])
|
---|
210 |
|
---|
211 | AT_CLEANUP
|
---|
212 |
|
---|
213 |
|
---|
214 |
|
---|
215 | ## ------------ ##
|
---|
216 | ## AS_MKDIR_P. ##
|
---|
217 | ## ------------ ##
|
---|
218 |
|
---|
219 | # Build nested dirs.
|
---|
220 | AT_SETUP([AS@&t@_MKDIR_P])
|
---|
221 |
|
---|
222 | AT_DATA_M4SH([script.as],
|
---|
223 | [[AS_INIT
|
---|
224 |
|
---|
225 | pwd=`pwd`
|
---|
226 | set -e
|
---|
227 | # Absolute
|
---|
228 | AS_MKDIR_P(["$pwd/1/2/3/4/5/6"])
|
---|
229 | test -d "$pwd/1/2/3/4/5/6" ||
|
---|
230 | AS_ERROR([$pwd/1/2/3/4/5/6 has not been properly created])
|
---|
231 | # Relative
|
---|
232 | AS_MKDIR_P(["a/b/c/d/e/f"])
|
---|
233 | test -d a/b/c/d/e/f ||
|
---|
234 | AS_ERROR([a/b/c/d/e/f has not been properly created])
|
---|
235 | AS_EXIT(0)
|
---|
236 | ]])
|
---|
237 |
|
---|
238 | AT_CHECK_M4SH
|
---|
239 | AT_CHECK([./script])
|
---|
240 |
|
---|
241 | AT_CLEANUP
|
---|
242 |
|
---|
243 |
|
---|
244 |
|
---|
245 |
|
---|
246 | ## -------------------- ##
|
---|
247 | ## AS_VERSION_COMPARE. ##
|
---|
248 | ## -------------------- ##
|
---|
249 |
|
---|
250 | # Build nested dirs.
|
---|
251 | AT_SETUP([AS@&t@_VERSION_COMPARE])
|
---|
252 |
|
---|
253 | AT_DATA_M4SH([script.as],
|
---|
254 | [[AS_INIT
|
---|
255 |
|
---|
256 | m4_define([VERSION_COMPARE_TEST],
|
---|
257 | [AS_VERSION_COMPARE([$1], [$3], [result='<'], [result='='], [result='>'])
|
---|
258 | test "X$result" = "X$2" ||
|
---|
259 | AS_ERROR([version $1 $result $3; should be $1 $2 $3])
|
---|
260 | m4_if([$1], <,
|
---|
261 | [AS_VERSION_COMPARE([$3], [$1], [result='<'], [result='='], [result='>'])
|
---|
262 | test "X$result" = "X>" ||
|
---|
263 | AS_ERROR([version $3 $result $1; should be $3 > $1])])])
|
---|
264 |
|
---|
265 | VERSION_COMPARE_TEST([], =, [])
|
---|
266 | VERSION_COMPARE_TEST([1.0], =, [1.0])
|
---|
267 | VERSION_COMPARE_TEST([alpha-1.0], =, [alpha-1.0])
|
---|
268 |
|
---|
269 | # These tests are taken from libc/string/tst-svc.expect.
|
---|
270 | tst_svc_expect='
|
---|
271 | 000 001 00 00a 01 01a 0 0a 2.8 2.8-0.4 20 21 22 212 CP037 CP345 CP1257
|
---|
272 | foo foo-0.4 foo-0.4a foo-0.4b foo-0.5 foo-0.10.5 foo-3.01 foo-3.0
|
---|
273 | foo-3.0.0 foo-3.0.1 foo-3.2 foo-3.10 foo00 foo0
|
---|
274 | '
|
---|
275 | test1=''
|
---|
276 | for test2 in $tst_svc_expect; do
|
---|
277 | VERSION_COMPARE_TEST([$test1], <, [$test2])
|
---|
278 | test1=$test2
|
---|
279 | done
|
---|
280 |
|
---|
281 | AS_EXIT(0)
|
---|
282 | ]])
|
---|
283 |
|
---|
284 | AT_CHECK_M4SH
|
---|
285 | AT_CHECK([./script])
|
---|
286 |
|
---|
287 | AT_CLEANUP
|
---|
288 |
|
---|
289 |
|
---|
290 |
|
---|
291 |
|
---|
292 | ## ----------------------------- ##
|
---|
293 | ## Negated classes in globbing. ##
|
---|
294 | ## ----------------------------- ##
|
---|
295 |
|
---|
296 | # It is known that `[^...]' is not universally supported, but it is
|
---|
297 | # unknown for `[!...]'.
|
---|
298 |
|
---|
299 | AT_SETUP([Negated classes in globbing])
|
---|
300 |
|
---|
301 | AT_DATA_M4SH([script.as],
|
---|
302 | [[AS_INIT
|
---|
303 |
|
---|
304 | case 'with!two!bangs' in
|
---|
305 | *[[!a-z]]*) ;;
|
---|
306 | *) AS_ERROR([[`*[!a-z]*' didn't match `with!two!bangs']]);;
|
---|
307 | esac
|
---|
308 |
|
---|
309 | case without in
|
---|
310 | *[[!a-z]]*) AS_ERROR([[`*[!a-z]*' matched `without']]);;
|
---|
311 | esac
|
---|
312 | ]])
|
---|
313 |
|
---|
314 | AT_CHECK_M4SH
|
---|
315 | AT_CHECK([./script])
|
---|
316 |
|
---|
317 | AT_CLEANUP
|
---|
318 |
|
---|
319 |
|
---|
320 |
|
---|
321 |
|
---|
322 | ## ------------------- ##
|
---|
323 | ## Functions Support. ##
|
---|
324 | ## ------------------- ##
|
---|
325 |
|
---|
326 | # Hypothesis: the shell we are running, after having checked for
|
---|
327 | # $LINENO support, supports functions.
|
---|
328 |
|
---|
329 | AT_SETUP([Functions Support])
|
---|
330 |
|
---|
331 | AT_DATA_M4SH([script.as],
|
---|
332 | [[AS_INIT
|
---|
333 | _AS_LINENO_PREPARE
|
---|
334 |
|
---|
335 | func_return () {
|
---|
336 | (exit $1)
|
---|
337 | }
|
---|
338 |
|
---|
339 | func_success () {
|
---|
340 | func_return 0
|
---|
341 | }
|
---|
342 |
|
---|
343 | func_failure () {
|
---|
344 | func_return 1
|
---|
345 | }
|
---|
346 |
|
---|
347 | if func_success; then
|
---|
348 | if func_failure; then
|
---|
349 | AS_ERROR([func_failure passed])
|
---|
350 | fi
|
---|
351 | else
|
---|
352 | AS_ERROR([func_success failed])
|
---|
353 | fi
|
---|
354 | ]])
|
---|
355 |
|
---|
356 | AT_CHECK_M4SH
|
---|
357 | AT_CHECK([./script])
|
---|
358 |
|
---|
359 | AT_CLEANUP
|
---|
360 |
|
---|
361 |
|
---|
362 |
|
---|
363 |
|
---|
364 | ## ------------------------------ ##
|
---|
365 | ## Functions and return Support. ##
|
---|
366 | ## ------------------------------ ##
|
---|
367 |
|
---|
368 | # Hypothesis: the shell we are running, after having checked for
|
---|
369 | # $LINENO support, supports functions, and the `return' keyword.
|
---|
370 |
|
---|
371 | AT_SETUP([Functions and return Support])
|
---|
372 |
|
---|
373 | AT_DATA_M4SH([script.as],
|
---|
374 | [[AS_INIT
|
---|
375 | _AS_LINENO_PREPARE
|
---|
376 |
|
---|
377 | func_success () {
|
---|
378 | return 0
|
---|
379 | }
|
---|
380 |
|
---|
381 | func_failure () {
|
---|
382 | return 1
|
---|
383 | }
|
---|
384 |
|
---|
385 | if func_success; then
|
---|
386 | if func_failure; then
|
---|
387 | AS_ERROR([func_failure passed])
|
---|
388 | fi
|
---|
389 | else
|
---|
390 | AS_ERROR([func_success failed])
|
---|
391 | fi
|
---|
392 | ]])
|
---|
393 |
|
---|
394 | AT_CHECK_M4SH
|
---|
395 | AT_CHECK([./script])
|
---|
396 |
|
---|
397 | AT_CLEANUP
|
---|
398 |
|
---|
399 |
|
---|
400 | ## ------------------------------------ ##
|
---|
401 | ## AS_REQUIRE_SHELL_FN and m4_require. ##
|
---|
402 | ## ------------------------------------ ##
|
---|
403 |
|
---|
404 | # Hypothesis: M4sh expands the requirements of AS_REQUIRE_SHELL_FN
|
---|
405 | # in the main diversion, and not in M4SH-INIT.
|
---|
406 |
|
---|
407 | AT_SETUP([AS@&t@_REQUIRE_SHELL_FN and m4@&t@_require])
|
---|
408 |
|
---|
409 | AT_DATA_M4SH([script.as], [[dnl
|
---|
410 | AS_INIT
|
---|
411 |
|
---|
412 | m4_defun([in_m4_sh_init], still_in_m4sh_init=yes)
|
---|
413 | m4_defun([not_in_m4_sh_init], still_in_m4sh_init=no)
|
---|
414 |
|
---|
415 | m4_defun([error_if_emitted_in_m4sh_init], [
|
---|
416 | if test x$still_in_m4sh_init = xyes; then
|
---|
417 | AS_ERROR([requirement emitted in M4SH-INIT])
|
---|
418 | fi
|
---|
419 | ])
|
---|
420 |
|
---|
421 | m4_defun([TEST_FUNC_BODY], [
|
---|
422 | m4_require([error_if_emitted_in_m4sh_init])
|
---|
423 | : echo in shell function, with parameter = [$]1
|
---|
424 | ])
|
---|
425 |
|
---|
426 |
|
---|
427 | m4_defun([test_init], [
|
---|
428 | AS_REQUIRE([in_m4_sh_init])
|
---|
429 | AS_REQUIRE_SHELL_FN([test_func], [TEST_FUNC_BODY])
|
---|
430 | AS_REQUIRE([not_in_m4_sh_init])
|
---|
431 | ])
|
---|
432 |
|
---|
433 | test_init
|
---|
434 | test_func parameter1
|
---|
435 | ]])
|
---|
436 |
|
---|
437 | AT_CHECK_M4SH
|
---|
438 | AT_CHECK([./script])
|
---|
439 |
|
---|
440 | AT_CLEANUP
|
---|
441 |
|
---|
442 |
|
---|
443 | ## -------------- ##
|
---|
444 | ## AS_HELP_STRING ##
|
---|
445 | ## -------------- ##
|
---|
446 |
|
---|
447 | # I'm not totally certain that we want to enforce the defaults here,
|
---|
448 | # but at least it is being tested.
|
---|
449 |
|
---|
450 | AT_SETUP([AS@&t@_HELP_STRING])
|
---|
451 |
|
---|
452 | AT_DATA_M4SH([script.as],
|
---|
453 | [[AS_INIT
|
---|
454 | _AS_LINENO_PREPARE
|
---|
455 |
|
---|
456 | echo "AS_HELP_STRING([--an-option],[some text])"
|
---|
457 | echo "AS_HELP_STRING([--another-much-longer-option],
|
---|
458 | [some other text which should wrap at our default of 80 characters.])"
|
---|
459 | echo "AS_HELP_STRING([--fooT=barT], [foo bar])"
|
---|
460 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@], [foo bar])"
|
---|
461 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789], [foo bar])"
|
---|
462 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890], [foo bar])"
|
---|
463 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901], [foo bar])"
|
---|
464 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012], [foo bar])"
|
---|
465 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123], [foo bar])"
|
---|
466 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
|
---|
467 | [some other text which should wrap at our default of 80 characters.])"
|
---|
468 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
|
---|
469 | [some other text which should wrap at our default of 80 characters.])"
|
---|
470 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
|
---|
471 | [some other text which should wrap at our default of 80 characters.])"
|
---|
472 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
|
---|
473 | [some other text which should wrap at our default of 80 characters.])"
|
---|
474 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
|
---|
475 | [some other text which should wrap at our default of 80 characters.])"
|
---|
476 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
|
---|
477 | [some other text which should wrap at our default of 80 characters.])"
|
---|
478 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
|
---|
479 | [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
|
---|
480 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
|
---|
481 | [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
|
---|
482 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
|
---|
483 | [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
|
---|
484 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
|
---|
485 | [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
|
---|
486 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
|
---|
487 | [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
|
---|
488 | echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
|
---|
489 | [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
|
---|
490 | ]])
|
---|
491 |
|
---|
492 | AT_CHECK_M4SH
|
---|
493 | AT_CHECK([./script], [0],
|
---|
494 | [[ --an-option some text
|
---|
495 | --another-much-longer-option
|
---|
496 | some other text which should wrap at our default of
|
---|
497 | 80 characters.
|
---|
498 | --fooT=barT foo bar
|
---|
499 | --foo[=bar] foo bar
|
---|
500 | --foo[=bar]123456789 foo bar
|
---|
501 | --foo[=bar]1234567890 foo bar
|
---|
502 | --foo[=bar]12345678901 foo bar
|
---|
503 | --foo[=bar]123456789012 foo bar
|
---|
504 | --foo[=bar]1234567890123
|
---|
505 | foo bar
|
---|
506 | --foo[=bar] some other text which should wrap at our default of
|
---|
507 | 80 characters.
|
---|
508 | --foo[=bar]123456789 some other text which should wrap at our default of
|
---|
509 | 80 characters.
|
---|
510 | --foo[=bar]1234567890 some other text which should wrap at our default of
|
---|
511 | 80 characters.
|
---|
512 | --foo[=bar]12345678901 some other text which should wrap at our default of
|
---|
513 | 80 characters.
|
---|
514 | --foo[=bar]123456789012 some other text which should wrap at our default of
|
---|
515 | 80 characters.
|
---|
516 | --foo[=bar]1234567890123
|
---|
517 | some other text which should wrap at our default of
|
---|
518 | 80 characters.
|
---|
519 | --foo[=bar] some other [ex] which should wrap at our default of
|
---|
520 | 80 characters.
|
---|
521 | --foo[=bar]123456789 some other [ex] which should wrap at our default of
|
---|
522 | 80 characters.
|
---|
523 | --foo[=bar]1234567890 some other [ex] which should wrap at our default of
|
---|
524 | 80 characters.
|
---|
525 | --foo[=bar]12345678901 some other [ex] which should wrap at our default of
|
---|
526 | 80 characters.
|
---|
527 | --foo[=bar]123456789012 some other [ex] which should wrap at our default of
|
---|
528 | 80 characters.
|
---|
529 | --foo[=bar]1234567890123
|
---|
530 | some other [ex] which should wrap at our default of
|
---|
531 | 80 characters.
|
---|
532 | ]])
|
---|
533 |
|
---|
534 | AT_CLEANUP
|
---|
535 |
|
---|
536 |
|
---|
537 | ## ------------------- ##
|
---|
538 | ## AS_IF and AS_CASE. ##
|
---|
539 | ## ------------------- ##
|
---|
540 |
|
---|
541 | AT_SETUP([AS@&t@_IF and AS@&t@_CASE])
|
---|
542 |
|
---|
543 | AT_DATA_M4SH([script.as], [[dnl
|
---|
544 | AS_INIT
|
---|
545 | # Syntax checks: cope with empty arguments.
|
---|
546 | AS_IF([:], [], [echo wrong])
|
---|
547 | AS_IF([:], [echo one], [echo wrong])
|
---|
548 | AS_IF([false], [echo wrong], [echo two])
|
---|
549 | AS_IF([false], [echo wrong])
|
---|
550 | # n-ary version
|
---|
551 | AS_IF([false], [echo wrong],
|
---|
552 | [:], [echo three])
|
---|
553 | AS_IF([false], [echo wrong],
|
---|
554 | [:], [echo four],
|
---|
555 | [echo wrong])
|
---|
556 | AS_IF([false], [echo wrong],
|
---|
557 | [false], [echo wrong])
|
---|
558 | AS_IF([false], [echo wrong],
|
---|
559 | [false], [echo wrong],
|
---|
560 | [echo five])
|
---|
561 | AS_IF([false], [echo wrong],
|
---|
562 | [false], [echo wrong],
|
---|
563 | [:], [echo six],
|
---|
564 | [echo wrong])
|
---|
565 | AS_CASE([foo])
|
---|
566 | AS_CASE([foo], [echo seven])
|
---|
567 | AS_CASE([foo],
|
---|
568 | [foo], [echo eight],
|
---|
569 | [echo wrong])
|
---|
570 | AS_CASE([foo],
|
---|
571 | [foo], [echo nine],
|
---|
572 | [*], [echo wrong])
|
---|
573 | AS_CASE([foo],
|
---|
574 | [bar], [echo wrong],
|
---|
575 | [foo], [echo ten],
|
---|
576 | [*], [echo wrong])
|
---|
577 |
|
---|
578 | # check that require works correctly
|
---|
579 | m4_for([n], 1, 9, [],
|
---|
580 | [m4_defun([FOO]n, [foo]n[=]n)dnl
|
---|
581 | m4_defun([BAR]n,
|
---|
582 | [m4_require([FOO]]n[)dnl
|
---|
583 | bar]n[=]n)[]dnl
|
---|
584 | ])
|
---|
585 |
|
---|
586 | AS_IF([:], [BAR1])
|
---|
587 | echo "foo1=$foo1 bar1=$bar1"
|
---|
588 | AS_IF([:], [], [BAR2])
|
---|
589 | echo "foo2=$foo2 bar2=$bar2"
|
---|
590 | AS_IF([false], [BAR3])
|
---|
591 | echo "foo3=$foo3 bar3=$bar3"
|
---|
592 | AS_IF([false], [], [BAR4])
|
---|
593 | echo "foo4=$foo4 bar4=$bar4"
|
---|
594 | AS_CASE([x], [x], [BAR5])
|
---|
595 | echo "foo5=$foo5 bar5=$bar5"
|
---|
596 | AS_CASE([x], [y], [BAR6])
|
---|
597 | echo "foo6=$foo6 bar6=$bar6"
|
---|
598 | AS_CASE([x],
|
---|
599 | [x], [:],
|
---|
600 | [BAR7])
|
---|
601 | echo "foo7=$foo7 bar7=$bar7"
|
---|
602 | AS_CASE([x],
|
---|
603 | [y], [:],
|
---|
604 | [BAR8])
|
---|
605 | echo "foo8=$foo8 bar8=$bar8"
|
---|
606 | AS_CASE([x],
|
---|
607 | [y], [:],
|
---|
608 | [x], [BAR9])
|
---|
609 | echo "foo9=$foo9 bar9=$bar9"
|
---|
610 | ]])
|
---|
611 |
|
---|
612 | AT_CHECK_M4SH
|
---|
613 | AT_CHECK([./script], [0], [[one
|
---|
614 | two
|
---|
615 | three
|
---|
616 | four
|
---|
617 | five
|
---|
618 | six
|
---|
619 | seven
|
---|
620 | eight
|
---|
621 | nine
|
---|
622 | ten
|
---|
623 | foo1=1 bar1=1
|
---|
624 | foo2=2 bar2=
|
---|
625 | foo3=3 bar3=
|
---|
626 | foo4=4 bar4=4
|
---|
627 | foo5=5 bar5=5
|
---|
628 | foo6=6 bar6=
|
---|
629 | foo7=7 bar7=
|
---|
630 | foo8=8 bar8=8
|
---|
631 | foo9=9 bar9=9
|
---|
632 | ]])
|
---|
633 |
|
---|
634 | AT_CLEANUP
|
---|
635 |
|
---|
636 |
|
---|
637 | ## --------------- ##
|
---|
638 | ## AS_LITERAL_IF. ##
|
---|
639 | ## --------------- ##
|
---|
640 |
|
---|
641 | AT_SETUP([AS@&t@_LITERAL_IF])
|
---|
642 |
|
---|
643 | AT_DATA_M4SH([script.as], [[dnl
|
---|
644 | AS_INIT
|
---|
645 | echo AS_LITERAL_IF([lit], [ok], [ERR]) 1
|
---|
646 | echo AS_LITERAL_IF([l$it], [ERR], [ok]) 2
|
---|
647 | echo AS_LITERAL_IF([l``it], [ERR], [ok]) 3
|
---|
648 | m4_define([mac], [lit])
|
---|
649 | echo AS_LITERAL_IF([mac], [ok], [ERR]) 4
|
---|
650 | echo AS_LITERAL_IF([mac($, ``)], [ok], [ERR]) 5
|
---|
651 | m4_define([mac], [l$it])
|
---|
652 | echo AS_LITERAL_IF([mac], [ERR], [ok]) 6
|
---|
653 | m4_define([mac], [l`it])
|
---|
654 | echo AS_LITERAL_IF([mac], [ERR], [ok]) 7
|
---|
655 | ]])
|
---|
656 |
|
---|
657 | AT_CHECK_M4SH
|
---|
658 | AT_CHECK([./script], [],
|
---|
659 | [[ok 1
|
---|
660 | ok 2
|
---|
661 | ok 3
|
---|
662 | ok 4
|
---|
663 | ok 5
|
---|
664 | ok 6
|
---|
665 | ok 7
|
---|
666 | ]])
|
---|
667 |
|
---|
668 | AT_CLEANUP
|
---|