5 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
6 # 2009, 2010 Free Software Foundation, Inc.
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 3 of the License, or
11 # (at your option) any later version.
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.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ## ------------------- ##
22 ## AS_WARN, AS_ERROR. ##
23 ## ------------------- ##
25 AT_SETUP([AS@&t@_WARN and AS@&t@_ERROR])
29 AT_DATA_M4SH([script.as],
31 AS_WARN([*watch out*])dnl
33 if test x"$die" != x; then
34 AS_ERROR([you're dead])dnl
43 AT_CHECK([$CONFIG_SHELL ./script], [],
45 ]], [[script: WARNING: *watch out*
47 AT_CHECK([die=: $CONFIG_SHELL ./script], [1],
48 [], [[script: WARNING: *watch out*
49 script: error: you're dead
54 AT_DATA_M4SH([script.as],
56 m4_define([gone], [AS_ERROR([really])])
57 m4_define([AS_MESSAGE_LOG_FD], [5])
58 exec AS_MESSAGE_LOG_FD>log.txt
59 AS_WARN([*watch out*])dnl
61 if test x"$die" != x; then
62 AS_ERROR([you're dead])dnl
68 exec AS_MESSAGE_LOG_FD>&-
72 AT_CHECK([$CONFIG_SHELL ./script], [],
74 ]], [[script: WARNING: *watch out*
76 AT_CHECK([[grep 'script:[0-9]*: WARNING: \*watch out\*' log.txt]], [], [ignore])
77 AT_CHECK([die=: $CONFIG_SHELL ./script], [1],
78 [], [[script: WARNING: *watch out*
79 script: error: you're dead
81 AT_CHECK([[grep 'script:[0-9]*: WARNING: \*watch out\*' log.txt]], [], [ignore])
82 AT_CHECK([[grep 'script:[0-9]*: error: you'\''re dead' log.txt]], [], [ignore])
86 ## ---------------- ##
88 ## ---------------- ##
93 # We cannot unset LINENO with Zsh, yet this test case relies on
94 # unsetting LINENO to compare its result when (i) LINENO is supported
95 # and when (ii) it is not.
96 # So just skip if the shell is ZSH.
97 AT_CHECK([test -n "${ZSH_VERSION+set}" && exit 77], ignore)
99 # AT_DATA_LINENO(FILE-NAME,
100 # UNSET-LINENO = true | false, COUNTER, COUNTER-RE)
101 # ----------------------------------------------------------------
102 # Produce the FILE-NAME M4sh script which uses the COUNTER LINENO or
103 # _oline_, which we can recognized via COUNTER-RE. Unset LINENO is
106 # Use COUNTER, COUNTER-RE = [__LINENO__], [LINENO]
107 # or = [__OLINE__], [_oline__]
109 # instead of the obvious $LINENO and __oline__, because they would
110 # be replaced in the test suite itself, even before creating these
111 # scripts. For the same reason, grep for LINENO and _oline__ (sic).
113 # UNSET-LINENO is a shell condition to make sure the scripts have the
114 # same number of lines in the output, so that their outputs be identical.
115 m4_define([AT_DATA_LINENO],
118 m4@&t@_divert_text([], [
120 AS@&t@_UNSET([LINENO])
123 AS@&t@_LINENO_PREPARE
125 grep 'Line: .*$4' "$[0]" >/dev/null ||
126 AS@&t@_ERROR([cannot find original script])
129 # If occurrences of $LINENO or __@&t@oline__ were wanted, create them.
130 sed 's/__LINENO__/$''LINENO/g;s/__OLINE__/__''oline__/g' $1.tas >$1.as
131 AT_CHECK([autom4te -l m4sh $1.as -o $1])
134 # `_oline_', once processed and ran, produces our reference.
135 # We check that we find ourselves by looking at a string which is
136 # available only in the original script: `_oline_'.
137 AT_DATA_LINENO([reference], [false], [__OLINE__], [_oline__])
138 AT_CHECK([./reference], 0, [stdout])
143 # Now using a maybe-functioning LINENO, with different call conventions.
144 # Be sure to be out of the PATH.
145 AT_CHECK([mkdir test || exit 77])
147 AT_DATA_LINENO([test/test-1], [false], [__LINENO__], [LINENO])
148 AT_CHECK([./test/test-1], 0, [expout])
149 AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-1)],
151 AT_CHECK([sh ./test/test-1], 0, [expout])
153 # Now using a disabled LINENO, with different call conventions.
154 AT_DATA_LINENO([test/test-2], [true], [__LINENO__], [LINENO])
155 AT_CHECK([./test/test-2], 0, [expout])
156 AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-2)],
158 AT_CHECK([sh ./test/test-2], 0, [expout])
163 ## ---------------------- ##
164 ## LINENO stack support. ##
165 ## ---------------------- ##
167 AT_SETUP([LINENO stack])
170 AT_DATA_M4SH([script.as],
173 AS_LINENO_PUSH([9999])
174 test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1])
175 AS_LINENO_PUSH([8888])
176 test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 2])
178 test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1])
180 test x${as_lineno+set} = xset && AS_ERROR([as_lineno set at depth 0])
186 AT_CHECK([$CONFIG_SHELL ./script])
195 # Output a framed one-line message.
196 AT_SETUP([AS@&t@_BOX])
199 AT_DATA_M4SH([script.as],
202 AS_BOX([Send a simple message, to foobar@example.com])
203 AS_BOX([Send a simple message, to foobar@example.com], [$])
204 m4_define([msg], [$complex])
205 complex='Not quite as simple |$[1]'
212 AT_CHECK([sed -n '/ -\{44\} /,/ -\{44\} /p' script ]dnl
213 [| sed '1 s/.*## -/## -/; 3 s/- ##.*/- ##/'], [],
214 [[## -------------------------------------------- ##
215 ## Send a simple message, to foobar@example.com ##
216 ## -------------------------------------------- ##
219 AT_CHECK([$CONFIG_SHELL ./script], [], [[
220 ## -------------------------------------------- ##
221 ## Send a simple message, to foobar@example.com ##
222 ## -------------------------------------------- ##
223 ## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
224 ## Send a simple message, to foobar@example.com ##
225 ## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
226 ## ----------------------- ##
227 ## Not quite as simple |$1 ##
228 ## ----------------------- ##
229 ## ,,,,,,,,,,,,,,,,,,,,,,, ##
230 ## Not quite as simple |$1 ##
231 ## ,,,,,,,,,,,,,,,,,,,,,,, ##
237 # Strip path from file.
238 AT_SETUP([AS@&t@_BASENAME])
241 AT_DATA_M4SH([script.as],
244 m4_define([BASENAME_TEST],
245 [base=`AS_BASENAME([$1])`
246 test "$base" = "$2" ||
247 echo "basename($1) = $base instead of $2" >&2
249 base=`_AS_BASENAME_SED([$1])`
250 test "$base" = "$2" ||
251 echo "basename_sed($1) = $base instead of $2" >&2])
253 BASENAME_TEST([//1], [1])
254 BASENAME_TEST([/1], [1])
255 BASENAME_TEST([./1], [1])
256 BASENAME_TEST([../../2], [2])
257 BASENAME_TEST([//1/], [1])
258 BASENAME_TEST([/1/], [1])
259 BASENAME_TEST([./1/], [1])
260 BASENAME_TEST([../../2], [2])
261 BASENAME_TEST([//1/3], [3])
262 BASENAME_TEST([/1/3], [3])
263 BASENAME_TEST([./1/3], [3])
264 BASENAME_TEST([../../2/3], [3])
265 BASENAME_TEST([//1/3///], [3])
266 BASENAME_TEST([/1/3///], [3])
267 BASENAME_TEST([./1/3///], [3])
268 BASENAME_TEST([../../2/3///], [3])
269 BASENAME_TEST([//1//3/], [3])
270 BASENAME_TEST([/1//3/], [3])
271 BASENAME_TEST([./1//3/], [3])
272 BASENAME_TEST([a.c], [a.c])
273 BASENAME_TEST([a.c/], [a.c])
274 BASENAME_TEST([/a.c/], [a.c])
275 BASENAME_TEST([/1/a.c], [a.c])
276 BASENAME_TEST([/1/a.c/], [a.c])
277 BASENAME_TEST([/1/../a.c], [a.c])
278 BASENAME_TEST([/1/../a.c/], [a.c])
279 BASENAME_TEST([./1/a.c], [a.c])
280 BASENAME_TEST([./1/a.c/], [a.c])
285 AT_CHECK([$CONFIG_SHELL ./script])
294 # Strip filename component.
295 AT_SETUP([AS@&t@_DIRNAME])
298 AT_DATA_M4SH([script.as],
301 # The EXPR variant is allowed to fail if `expr' was considered as too
302 # weak for us, in which case `as_expr=false'.
303 m4_define([DIRNAME_TEST],
304 [dir=`AS_DIRNAME([$1])`
305 test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
306 echo "dirname($1) = $dir instead of $2" >&2
308 if test "$as_expr" != false; then
309 dir=`_AS_DIRNAME_EXPR([$1])`
310 test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
311 echo "dirname_expr($1) = $dir instead of $2" >&2
314 dir=`_AS_DIRNAME_SED([$1])`
315 test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
316 echo "dirname_sed($1) = $dir instead of $2" >&2])
318 DIRNAME_TEST([/], [/])
319 DIRNAME_TEST([//], [//], [/])
320 DIRNAME_TEST([///], [/])
321 DIRNAME_TEST([//1], [//], [/])
322 DIRNAME_TEST([/1], [/])
323 DIRNAME_TEST([./1], [.])
324 DIRNAME_TEST([../../2], [../..])
325 DIRNAME_TEST([//1/], [//], [/])
326 DIRNAME_TEST([/1/], [/])
327 DIRNAME_TEST([./1/], [.])
328 DIRNAME_TEST([../../2], [../..])
329 DIRNAME_TEST([//1/3], [//1])
330 DIRNAME_TEST([/1/3], [/1])
331 DIRNAME_TEST([./1/3], [./1])
332 DIRNAME_TEST([../../2/3], [../../2])
333 DIRNAME_TEST([//1/3///], [//1])
334 DIRNAME_TEST([/1/3///], [/1])
335 DIRNAME_TEST([./1/3///], [./1])
336 DIRNAME_TEST([../../2/3///], [../../2])
337 DIRNAME_TEST([//1//3/], [//1])
338 DIRNAME_TEST([/1//3/], [/1])
339 DIRNAME_TEST([./1//3/], [./1])
340 DIRNAME_TEST([../../2//3/], [../../2])
345 AT_CHECK([$CONFIG_SHELL ./script])
350 ## ---------------- ##
351 ## AS_SET_CATFILE. ##
352 ## ---------------- ##
354 AT_SETUP([AS@&t@_SET_CATFILE])
357 AT_DATA_M4SH([script.as],
360 # CATFILE_TEST(DIR, FILE, EXPECTED)
361 m4_define([CATFILE_TEST],
362 [# AS_SET_CATFILE works and can be used in a compound list.
363 if AS_SET_CATFILE([var], [$1], [$2]) \
364 && test "$var" = $3; then :; else
365 echo "catfile($1, $2) = $var != $3" >&2
367 # AS_SET_CATFILE can use non-literals in its arguments.
371 if AS_SET_CATFILE([$varname], [$dirpart], [$filepart]) \
372 && test "$var2" = $3; then :; else
373 echo "catfile($dirpart, $filepart) = $var2 != $3" >&2
377 CATFILE_TEST([dir], [file], [dir/file])
378 CATFILE_TEST([.], [file], [file])
379 CATFILE_TEST([dir], [.], [dir])
380 CATFILE_TEST([dir], [/abs/file], [/abs/file])
381 CATFILE_TEST([dir], [C:/abs/file], [C:/abs/file])
382 CATFILE_TEST(["dir name"], ['file name'], ['dir name/file name'])
388 AT_CHECK([$CONFIG_SHELL ./script])
397 # Print literal strings, with/without newline.
398 AT_SETUP([AS@&t@_ECHO and AS@&t@_ECHO_N])
401 AT_DATA_M4SH([script.as],
404 m4_define([ECHO_TEST],
405 [echo=`AS_ECHO(['$1'])`
406 test "X$echo" = 'X$1' ||
407 echo "AS@&t@_ECHO('"'$1'"') outputs '$echo'" >&2
409 echo=`AS_ECHO_N(['$1'])`
410 test "X$echo" = 'X$1' ||
411 echo "AS@&t@_ECHO_N('"'$1'"') outputs '$echo'" >&2])
415 ECHO_TEST([---...---])
424 ECHO_TEST([\a\b\c\f\n\r\t\v\"\])
436 AT_CHECK([$CONFIG_SHELL ./script])
446 # Exit scripts with given status.
447 AT_SETUP([AS@&t@_EXIT])
448 AT_KEYWORDS([m4sh AS@&t@_SET_STATUS])
450 AT_DATA_M4SH([script.as],
452 test x${1} = xa && AS_EXIT
453 test x${1} = xb && AS_EXIT([${2}])
454 test x${1} = xc && { AS_SET_STATUS([${2}]); AS_EXIT; }
455 test x${1} = xd && trap 's=$?; echo $s; AS_EXIT([$s])' 0
456 test x${2} = xe && set -e
457 test $[#] -gt 0 || AS_EXIT
459 dnl Solaris /bin/sh 'set -e' doesn't react to failed function calls
461 && { echo 'skipping rest of test: set -e support is lousy'; exit 77; }
466 AT_CHECK([$CONFIG_SHELL ./script], [1])
467 AT_CHECK([$CONFIG_SHELL ./script ''], [4])
468 AT_CHECK([$CONFIG_SHELL ./script a], [0])
469 AT_CHECK([$CONFIG_SHELL ./script b], [0])
470 AT_CHECK([$CONFIG_SHELL ./script b 0], [0])
471 AT_CHECK([$CONFIG_SHELL ./script b 2], [2])
472 AT_CHECK([$CONFIG_SHELL ./script c 0], [0])
473 AT_CHECK([$CONFIG_SHELL ./script c 2], [2])
474 AT_CHECK([$CONFIG_SHELL ./script d], [4], [[4
476 dnl If we got to this point without a FAIL, then AS_EXIT at least works.
477 dnl The rest of this test relies on semi-decent 'set -e' support, even
478 dnl though m4sh in general should not try to rely on it because of
479 dnl portability nightmares on what constructs are considered errors across
480 dnl various shells; therefore, an overall SKIP result is desirable on
481 dnl broken shells like Solaris /bin/sh.
482 AT_CHECK([$CONFIG_SHELL ./script '' e], [3])
483 AT_CHECK([$CONFIG_SHELL ./script d e], [3], [stdout])
484 dnl NetBSD sh fails to output on stderr here.
485 AT_CHECK([grep 3 stdout || exit 77], [], [ignore])
496 AT_SETUP([AS@&t@_MKDIR_P])
499 AT_DATA_M4SH([script.as],
505 AS_MKDIR_P(["$pwd/1/2/3/4/5/6"])
506 test -d "$pwd/1/2/3/4/5/6" ||
507 AS_ERROR([$pwd/1/2/3/4/5/6 has not been properly created])
509 AS_MKDIR_P(["a/b/c/d/e/f"])
510 test -d a/b/c/d/e/f ||
511 AS_ERROR([a/b/c/d/e/f has not been properly created])
516 AT_CHECK([$CONFIG_SHELL ./script])
523 ## -------------------- ##
524 ## AS_VERSION_COMPARE. ##
525 ## -------------------- ##
527 # Three-way version comparison.
528 AT_SETUP([AS@&t@_VERSION_COMPARE])
531 AT_DATA_M4SH([script.as],
534 m4_define([VERSION_COMPARE_TEST],
535 [AS_VERSION_COMPARE([$1], [$3], [result='<'], [result='='], [result='>'])
536 test "X$result" = "X$2" ||
537 AS_ERROR([version $1 $result $3; should be $1 $2 $3])
539 [AS_VERSION_COMPARE([$3], [$1], [result='<'], [result='='], [result='>'])
540 test "X$result" = "X>" ||
541 AS_ERROR([version $3 $result $1; should be $3 > $1])])])
543 VERSION_COMPARE_TEST([], =, [])
544 VERSION_COMPARE_TEST([1.0], =, [1.0])
545 VERSION_COMPARE_TEST([alpha-1.0], =, [alpha-1.0])
547 # These tests are taken from libc/string/tst-svc.expect.
549 000 001 00 00a 01 01a 0 0a 2.8 2.8-0.4 20 21 22 212 CP037 CP345 CP1257
550 foo foo-0.4 foo-0.4a foo-0.4b foo-0.5 foo-0.10.5 foo-3.01 foo-3.0
551 foo-3.0.0 foo-3.0.1 foo-3.2 foo-3.10 foo00 foo0
554 for test2 in $tst_svc_expect; do
555 VERSION_COMPARE_TEST([$test1], <, [$test2])
563 AT_CHECK([$CONFIG_SHELL ./script])
577 AT_DATA_M4SH([script.as],
580 test "$as_me" = script || AS_ECHO([["incorrect value of \$as_me: $as_me"]])
584 AT_CHECK([$CONFIG_SHELL ./script])
591 ## ----------------------------- ##
592 ## Negated classes in globbing. ##
593 ## ----------------------------- ##
595 # According to http://www.in-ulm.de/~mascheck/bourne/, all shells with
596 # functions also support `[!...]'. But `[^...]' is not universally supported.
598 AT_SETUP([Negated classes in globbing])
601 AT_DATA_M4SH([script.as],
604 case 'with!two!bangs' in
606 *) AS_ERROR([[`*[!a-z]*' didn't match `with!two!bangs']]);;
610 *[[!a-z]]*) AS_ERROR([[`*[!a-z]*' matched `without']]);;
615 AT_CHECK([$CONFIG_SHELL ./script])
619 ## ---------------------------- ##
620 ## Null variable substitution. ##
621 ## ---------------------------- ##
623 # According to http://www.in-ulm.de/~mascheck/bourne/, all shells with
624 # functions also support `${a:-b}'.
626 AT_SETUP([Null variable substitution])
629 AT_DATA_M4SH([script.as],
635 case ${a:-x}${b:-y}${c:-z} in
639 case ${a-x}${b-y}${c-z} in
644 case ${a+x}${b+y}${c+z} in
648 case ${a:+x}${b:+y}${c:+z} in
653 case ${a=x}${b=y}${c=z} in
658 case ${a:=x}${b:=y}${c:=z} in
669 (: ${a?oops}; echo fail) 2>err && exit 8
670 grep oops err >/dev/null || exit 9
671 test "${b?oops}" = '' || exit 10
672 test "${c?oops}" = . || exit 11
673 (: ${a:?oops}; echo fail) 2>err && exit 12
674 grep oops err >/dev/null || exit 13
675 (: ${b:?oops}; echo fail) 2>err && exit 14
676 grep oops err >/dev/null || exit 15
677 test "${c:?oops}" = . || exit 16
681 AT_CHECK([$CONFIG_SHELL ./script])
686 ## ------------------- ##
687 ## Functions Support. ##
688 ## ------------------- ##
690 # All m4sh scripts require function support.
692 AT_SETUP([Functions Support])
695 AT_DATA_M4SH([script.as],
711 if func_success; then
712 if func_failure; then
713 AS_ERROR([func_failure passed])
716 AS_ERROR([func_success failed])
721 AT_CHECK([$CONFIG_SHELL ./script])
728 ## ------------------------------ ##
729 ## Functions and return Support. ##
730 ## ------------------------------ ##
732 # All m4sh scripts require working return within functions.
734 AT_SETUP([Functions and return Support])
737 AT_DATA_M4SH([script.as],
749 if func_success; then
750 if func_failure; then
751 AS_ERROR([func_failure passed])
754 AS_ERROR([func_success failed])
759 AT_CHECK([$CONFIG_SHELL ./script])
764 ## --------------------------- ##
765 ## Nested AS_REQUIRE_SHELL_FN. ##
766 ## --------------------------- ##
768 # Hypothesis: M4sh expands nested AS_REQUIRE_SHELL_FN
771 AT_SETUP([Nested AS@&t@_REQUIRE_SHELL_FN])
774 AT_DATA_M4SH([script.as], [[dnl
775 m4_define([INIT], [oops])dnl
778 m4_defun([TEST_FUNC2_BODY], [
782 m4_defun([TEST_FUNC1_BODY], [
783 AS_REQUIRE_SHELL_FN([test_func2], [], [TEST_FUNC2_BODY])
787 AS_REQUIRE_SHELL_FN([test_func1], [], [TEST_FUNC1_BODY])
792 AT_CHECK([$CONFIG_SHELL ./script])
797 ## ------------------- ##
798 ## Nested AS_REQUIRE. ##
799 ## ------------------- ##
801 # Hypothesis: M4sh expands the requirements of AS_REQUIRE in the
802 # requested diversion, even if other AS_REQUIREs are interleaved.
804 AT_SETUP([Nested AS@&t@_REQUIRE])
807 AT_DATA_M4SH([script.as], [[dnl
810 m4_defun([in_fn_diversion], still_in_m4sh_init_fn=yes)
811 m4_defun([not_in_fn_diversion], still_in_m4sh_init_fn=no)
813 m4_defun([NESTED], [nested_require_in_fn_diversion=$still_in_m4sh_init_fn])
815 m4_defun([OUTER], [AS_REQUIRE([NESTED])dnl
816 outer_require_in_fn_diversion=$still_in_m4sh_init_fn])
818 m4_defun([test_init], [
819 AS_REQUIRE([in_fn_diversion], , [M4SH-INIT-FN])
820 AS_REQUIRE([OUTER], , [M4SH-INIT-FN])
821 AS_REQUIRE([not_in_fn_diversion], , [M4SH-INIT-FN])
825 if test $outer_require_in_fn_diversion != yes; then AS_EXIT([1]); fi
826 if test $nested_require_in_fn_diversion != no; then AS_EXIT([1]); fi
830 AT_CHECK([$CONFIG_SHELL ./script])
835 ## ------------------------------------ ##
836 ## AS_REQUIRE_SHELL_FN and m4_require. ##
837 ## ------------------------------------ ##
839 # Hypothesis: M4sh expands the requirements of AS_REQUIRE_SHELL_FN
840 # in M4SH-INIT-FN. This changed after Autoconf 2.63.
842 AT_SETUP([AS@&t@_REQUIRE_SHELL_FN and m4@&t@_require])
845 AT_DATA_M4SH([script.as], [[dnl
848 m4_defun([in_m4_sh_init], still_in_m4sh_init=yes)
849 m4_defun([not_in_m4_sh_init], still_in_m4sh_init=no)
851 m4_defun([error_if_emitted_in_m4sh_init], [
852 if test x$still_in_m4sh_init = xyes; then
853 AS_ERROR([requirement emitted in M4SH-INIT])
857 m4_defun([TEST_FUNC_BODY], [
858 m4_require([error_if_emitted_in_m4sh_init])
859 : echo in shell function, with parameter = [$]1
863 m4_defun([test_init], [
864 AS_REQUIRE([in_m4_sh_init], , [M4SH-INIT-FN])
865 AS_REQUIRE_SHELL_FN([test_func], [], [TEST_FUNC_BODY])
866 AS_REQUIRE([not_in_m4_sh_init])
874 AT_CHECK([$CONFIG_SHELL ./script])
883 AT_SETUP([AS@&t@_HELP_STRING])
884 AT_KEYWORDS([m4sh m4@&t@_text_wrap m4@&t@_expand])
886 AT_DATA_M4SH([script.as],
889 echo "AS_HELP_STRING([--an-option],[some text])"
890 echo "AS_HELP_STRING([--another-much-longer-option],
891 [some other text which should wrap at our default of 80 characters.])"
892 echo "AS_HELP_STRING([--fooT=barT], [foo bar])"
893 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@], [foo bar])"
894 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789], [foo bar])"
895 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890], [foo bar])"
896 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901], [foo bar])"
897 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012], [foo bar])"
898 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123], [foo bar])"
899 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
900 [some other text which should wrap at our default of 80 characters.])"
901 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
902 [some other text which should wrap at our default of 80 characters.])"
903 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
904 [some other text which should wrap at our default of 80 characters.])"
905 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
906 [some other text which should wrap at our default of 80 characters.])"
907 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
908 [some other text which should wrap at our default of 80 characters.])"
909 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
910 [some other text which should wrap at our default of 80 characters.])"
911 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
912 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
913 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
914 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
915 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
916 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
917 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
918 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
919 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
920 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
921 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
922 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
923 echo "AS_HELP_STRING([[--foo[=bar]]],
924 [some other t[]t which should wrap at our default of 80 characters.])"
925 echo "AS_HELP_STRING([[--foo[=bar]123456789]],
926 [some other t[]t which should wrap at our default of 80 characters.])"
927 echo "AS_HELP_STRING([[--foo[=bar]1234567890]],
928 [some other t[]t which should wrap at our default of 80 characters.])"
929 echo "AS_HELP_STRING([[--foo[=bar]12345678901]],
930 [some other t[]t which should wrap at our default of 80 characters.])"
931 echo "AS_HELP_STRING([[--foo[=bar]123456789012]],
932 [some other t[]t which should wrap at our default of 80 characters.])"
933 echo "AS_HELP_STRING([[--foo[=bar]1234567890123]],
934 [some other t[]t which should wrap at our default of 80 characters.])"
935 m4_define([mac], [MACRO])dnl
936 echo "AS_HELP_STRING([--mac], [mac])"
937 echo "AS_HELP_STRING([--o1, --o2], [two
938 options, one description])"
939 echo "AS_HELP_STRING([[[--o3, --o4]]], [comma inside literal quoting])"
940 echo "AS_HELP_STRING([--tune1], [check out the tuned formatting],
942 echo "AS_HELP_STRING([--tune2], [check out the tuned formatting],
944 echo "AS_HELP_STRING([--tune3], [check out the tuned formatting],
946 echo "AS_HELP_STRING([--tune4], [check out the tuned formatting],
951 AT_CHECK([$CONFIG_SHELL ./script], [0],
952 [[ --an-option some text
953 --another-much-longer-option
954 some other text which should wrap at our default of
958 --foo[=bar]123456789 foo bar
959 --foo[=bar]1234567890 foo bar
960 --foo[=bar]12345678901 foo bar
961 --foo[=bar]123456789012 foo bar
962 --foo[=bar]1234567890123
964 --foo[=bar] some other text which should wrap at our default of
966 --foo[=bar]123456789 some other text which should wrap at our default of
968 --foo[=bar]1234567890 some other text which should wrap at our default of
970 --foo[=bar]12345678901 some other text which should wrap at our default of
972 --foo[=bar]123456789012 some other text which should wrap at our default of
974 --foo[=bar]1234567890123
975 some other text which should wrap at our default of
977 --foo[=bar] some other [ex] which should wrap at our default of
979 --foo[=bar]123456789 some other [ex] which should wrap at our default of
981 --foo[=bar]1234567890 some other [ex] which should wrap at our default of
983 --foo[=bar]12345678901 some other [ex] which should wrap at our default of
985 --foo[=bar]123456789012 some other [ex] which should wrap at our default of
987 --foo[=bar]1234567890123
988 some other [ex] which should wrap at our default of
990 --foo[=bar] some other t[]t which should wrap at our default of
992 --foo[=bar]123456789 some other t[]t which should wrap at our default of
994 --foo[=bar]1234567890 some other t[]t which should wrap at our default of
996 --foo[=bar]12345678901 some other t[]t which should wrap at our default of
998 --foo[=bar]123456789012 some other t[]t which should wrap at our default of
1000 --foo[=bar]1234567890123
1001 some other t[]t which should wrap at our default of
1004 --o1, --o2 two options, one description
1005 [--o3, --o4] comma inside literal quoting
1006 --tune1 check out the tuned formatting
1007 --tune2 check out the tuned formatting
1008 --tune3 check out the
1011 --tune4 check out the tuned
1018 ## ------------------- ##
1019 ## AS_IF and AS_CASE. ##
1020 ## ------------------- ##
1022 AT_SETUP([AS@&t@_IF and AS@&t@_CASE])
1023 AT_KEYWORDS([m4sh m4@&t@_map_args_pair])
1025 AT_DATA_M4SH([script.as], [[dnl
1027 # Syntax checks: cope with empty arguments.
1028 AS_IF([:], [], [echo wrong])
1029 AS_IF([:], [echo one], [echo wrong])
1030 AS_IF([false], [echo wrong], [echo two])
1031 AS_IF([false], [echo wrong])
1033 AS_IF([false], [echo wrong],
1035 AS_IF([false], [echo wrong],
1038 AS_IF([false], [echo wrong],
1039 [false], [echo wrong])
1040 AS_IF([false], [echo wrong],
1041 [false], [echo wrong],
1043 AS_IF([false], [echo wrong],
1044 [false], [echo wrong],
1048 AS_CASE([foo], [echo seven])
1050 [foo], [echo eight],
1056 [bar], [echo wrong],
1060 # check for nesting, lists, and side effects, and quoting robustness
1062 AS_IF([AS_IF([$empty], [echo eleven])]) && AS_CASE([foo]) && echo twelve
1064 AS_IF([touch file; false]) && echo thirteen
1065 test -f file && echo fourteen
1067 AS_CASE([`touch file; false`]) && test -f file && echo fifteen
1068 dnl The next line is badly underquoted; don't intentionally copy this style.
1069 AS_CASE([foo], [foo], m4_do(AS_CASE([bar], [bar], [echo sixteen])))
1070 dnl Handle blank arguments.
1071 AS_IF([false], [:], [ ]) && AS_CASE([foo], [foo], []
1073 m4_define([empty])AS_IF([:], [empty]
1074 ) && AS_CASE([foo], [foo], [empty]) && echo eighteen
1075 dnl We can't handle AS_IF([false], [:], [empty]) unless m4_expand is
1076 dnl taught how to handle m4_require. The user is responsible for
1077 dnl avoiding the syntax error in that case.
1079 # check that require works correctly
1080 m4_for([n], 1, 9, [],
1081 [m4_defun([FOO]n, [foo]n[=]n)dnl
1083 [m4_require([FOO]]n[)dnl
1088 echo "foo1=$foo1 bar1=$bar1"
1089 AS_IF([:], [], [BAR2])
1090 echo "foo2=$foo2 bar2=$bar2"
1091 AS_IF([false], [BAR3])
1092 echo "foo3=$foo3 bar3=$bar3"
1093 AS_IF([false], [], [BAR4])
1094 echo "foo4=$foo4 bar4=$bar4"
1095 AS_CASE([x], [x], [BAR5])
1096 echo "foo5=$foo5 bar5=$bar5"
1097 AS_CASE([x], [y], [BAR6])
1098 echo "foo6=$foo6 bar6=$bar6"
1102 echo "foo7=$foo7 bar7=$bar7"
1106 echo "foo8=$foo8 bar8=$bar8"
1110 echo "foo9=$foo9 bar9=$bar9"
1114 AT_CHECK([$CONFIG_SHELL ./script], [0], [[one
1143 dnl stress test for large number of conditionals
1144 dnl too large, and we start tickling shell bugs
1145 m4_pushdef([limit], [1000])dnl
1146 AT_DATA_M4SH([script.as], [[dnl
1148 AS_IF(m4_shift(m4_for([i], [1], ]limit[, [], [, test $[1] = i, echo i])))
1149 AS_IF(m4_shift(m4_for([i], [1], ]limit[, [], [, test $[1] = i, echo i])),
1151 AS_CASE([$[1]]m4_for([i], [1], ]limit[, [], [, i, echo i]))
1152 AS_CASE([$[1]]m4_for([i], [1], ]limit[, [], [, i, echo i]), [echo default])
1155 dnl Add --force so autom4te doesn't think `script' is still up to date.
1156 AT_CHECK_M4SH([--force])
1157 AT_CHECK([$CONFIG_SHELL ./script 1], [0], [[1
1162 AT_CHECK([$CONFIG_SHELL ./script limit], [0], [limit
1167 AT_CHECK([$CONFIG_SHELL ./script default], [0], [[default
1179 AT_SETUP([AS@&t@_FOR])
1182 AT_DATA_M4SH([script.as], [[dnl
1186 AS_FOR([m4var], [shvar], [a],
1187 [echo "m4var $shvar"])
1188 AS_FOR([m4var], [shvar], [b c],
1189 [echo "m4var $shvar"])
1191 AS_FOR([m4var], [shvar], [$list],
1192 [echo "m4var $shvar"])
1193 AS_FOR([m4var], [shvar], ["$list"],
1194 [echo "m4var $shvar"])
1195 AS_FOR([m4var], [shvar], ['$list'],
1196 [echo "m4var $shvar"])
1197 AS_FOR([m4var], [shvar], [\'],
1198 [echo "m4var $shvar"])
1200 # Syntax checks: cope with empty/blank arguments.
1202 AS_FOR([], [shvar], [],
1203 [echo "m4_defn([]) $shvar"])
1205 AS_FOR([], [shvar], [`touch file`])
1206 test -f file || exit 1
1207 AS_FOR([], [shvar], [], [ ])
1208 m4_define([empty])AS_FOR([], [shvar], [], [empty])
1210 # Check that break works.
1213 AS_FOR([m4var], [shvar], [h i],
1214 [echo "m4var"; break 2])
1219 AS_FOR([m4var], [shvar], [j],
1220 [echo "m4var"; break 2])
1226 AT_CHECK([$CONFIG_SHELL ./script], [0], [[a a
1243 ## --------------- ##
1244 ## AS_LITERAL_IF. ##
1245 ## --------------- ##
1247 AT_SETUP([AS@&t@_LITERAL_IF])
1248 AT_KEYWORDS([m4sh AS@&t@_LITERAL_WORD_IF AS@&t@_LITERAL_HEREDOC_IF])
1250 AT_DATA_M4SH([script.as], [[dnl
1252 echo AS_LITERAL_IF([lit], [ok], [ERR]) 1
1253 echo AS_LITERAL_IF([l-/.it], [ok], [ERR]) 2
1254 echo AS_LITERAL_IF([l''it], [ERR], [ok]) 3
1255 echo AS_LITERAL_IF([l$it], [ERR], [ok]) 4
1256 echo AS_LITERAL_IF([l$it], [ERR1], [ERR2], [ok]) 5
1257 echo AS_LITERAL_IF([l${it}], [ERR1], [ERR2], [ok]) 6
1258 echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR], [ok]) 7
1259 echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR1], [ok], [ERR2]) 8
1260 m4_define([mac], [l-/.it])
1261 echo AS_LITERAL_IF([mac], [ok], [ERR]) 9
1262 echo AS_LITERAL_IF([mac($, ``)], [ok], [ERR]) 10
1263 m4_define([mac], [l$it])
1264 echo AS_LITERAL_IF([mac], [ERR], [ok]) 11
1265 echo AS_LITERAL_IF([mac], [ERR1], [ERR2], [ok]) 12
1266 m4_define([mac], [l``it])
1267 echo AS_LITERAL_IF([mac], [ERR], [ok]) 13
1268 echo AS_LITERAL_IF([mac], [ERR1], [ok], [ERR2]) 14
1269 echo AS_LITERAL_IF([ a ][
1271 echo AS_LITERAL_WORD_IF([ a ][
1273 echo AS_LITERAL_HEREDOC_IF([ a ][
1275 echo AS_LITERAL_IF([(a)], [ERR], [ok]) 18
1276 echo AS_LITERAL_WORD_IF([(a)], [ERR], [ok]) 19
1277 echo AS_LITERAL_HEREDOC_IF([(a)], [ok], [ERR]) 20
1278 echo AS_LITERAL_IF([@S|@a], [ERR], [ok]) 21
1279 echo AS_LITERAL_WORD_IF([@S|@a], [ERR], [ok]) 22
1280 echo AS_LITERAL_HEREDOC_IF([@S|@a], [ERR], [ok]) 23
1281 echo AS_LITERAL_IF([${a+b}], [ERR1], [ok], [ERR2]) 24
1282 echo AS_LITERAL_IF([${a=b}], [ERR1], [ok], [ERR2]) 25
1283 echo AS_LITERAL_IF([a+b], [ok], [ERR1], [ERR2]) 26
1284 echo AS_LITERAL_IF([a=b], [ok], [ERR1], [ERR2]) 27
1288 AT_CHECK([$CONFIG_SHELL ./script], [],
1321 ## --------------------- ##
1322 ## AS_TR_SH, AS_TR_CPP. ##
1323 ## --------------------- ##
1325 AT_SETUP([AS@&t@_TR_SH and AS@&t@_TR_CPP])
1327 AT_DATA_M4SH([script.as], [[dnl
1329 m4_define([abc], [hI])m4_define([ABC], [Hi])
1330 m4_define([hi], [oops])m4_define([HI], [OOPS])
1331 echo AS_TR_SH(abc) AS_TR_SH(aBc) AS_TR_SH(ABC)
1332 echo AS_TR_SH([abc]) AS_TR_SH([aBc]) AS_TR_SH([ABC])
1333 echo AS_TR_SH([[abc]]) AS_TR_SH([[aBc]]) AS_TR_SH([[ABC]])
1334 echo AS_TR_CPP(abc) AS_TR_CPP(aBc) AS_TR_CPP(ABC)
1335 echo AS_TR_CPP([abc]) AS_TR_CPP([aBc]) AS_TR_CPP([ABC])
1336 echo AS_TR_CPP([[abc]]) AS_TR_CPP([[aBc]]) AS_TR_CPP([[ABC]])
1338 [var=abc vAr=aBc VAR=ABC]
1339 echo AS_TR_SH($var) AS_TR_SH($vAr) AS_TR_SH($VAR)
1340 echo AS_TR_SH([$var]) AS_TR_SH([$vAr]) AS_TR_SH([$VAR])
1341 echo AS_TR_SH([[$var]]) AS_TR_SH([[$vAr]]) AS_TR_SH([[$VAR]])
1342 echo AS_TR_CPP($var) AS_TR_CPP($vAr) AS_TR_CPP($VAR)
1343 echo AS_TR_CPP([$var]) AS_TR_CPP([$vAr]) AS_TR_CPP([$VAR])
1344 echo AS_TR_CPP([[$var]]) AS_TR_CPP([[$vAr]]) AS_TR_CPP([[$VAR]])
1346 echo AS_TR_SH(`echo abc`) AS_TR_SH(`echo aBc`) AS_TR_SH(`echo ABC`)
1347 echo AS_TR_SH([`echo abc`]) AS_TR_SH([`echo aBc`]) AS_TR_SH([`echo ABC`])
1348 echo AS_TR_SH([[`echo abc`]]) AS_TR_SH([[`echo aBc`]]) AS_TR_SH([[`echo ABC`]])
1349 echo AS_TR_CPP(`echo abc`) AS_TR_CPP(`echo aBc`) AS_TR_CPP(`echo ABC`)
1350 echo AS_TR_CPP([`echo abc`]) AS_TR_CPP([`echo aBc`]) AS_TR_CPP([`echo ABC`])
1351 echo AS_TR_CPP([[`echo abc`]]) AS_TR_CPP([[`echo aBc`]]) AS_TR_CPP([[`echo ABC`]])
1354 echo AS_TR_SH([a.b/c+*-=])
1355 echo AS_TR_CPP([a.b/c+*-=])
1357 echo AS_TR_SH([$var])
1358 echo AS_TR_CPP([$var])
1359 m4_define([macro], [a.b/c+*-=])
1360 echo AS_TR_SH([macro])
1361 echo AS_TR_CPP([macro])
1365 AT_CHECK([$CONFIG_SHELL ./script], [],
1395 dnl Check that of the last 6 macros, only 2 needed command substitution.
1396 dnl This test abuses our knowledge of m4sh internals a bit; oh well.
1397 AT_CHECK([sed -n '/start here/,$ {
1399 }' script | wc -l], [], [[2
1409 AT_SETUP([AS@&t@_VAR basics])
1410 AT_KEYWORDS([m4sh AS@&t@_VAR_COPY AS@&t@_VAR_SET AS@&t@_VAR_GET])
1411 AT_KEYWORDS([AS@&t@_VAR_TEST_SET AS@&t@_VAR_SET_IF AS@&t@_VAR_IF])
1412 AT_KEYWORDS([AS@&t@_VAR_PUSHDEF AS@&t@_VAR_POPDEF])
1414 AT_DATA_M4SH([script.as], [[dnl
1416 m4_define([with], [WITH])
1418 dnl AS_VAR_SET_IF also covers AS_VAR_TEST_SET
1419 AS_VAR_SET_IF([foo], [echo oops]) && echo ok
1420 AS_VAR_IF([foo], [], [echo ok], [echo oops])
1422 AS_VAR_SET_IF([foo], [echo ok])
1423 AS_VAR_SET([foo], ['\a "weird" `value` with; $fun '\''characters
1425 AS_VAR_COPY([bar], [foo])
1427 AS_ECHO(["AS_VAR_GET([foo])-"])
1428 AS_VAR_SET_IF([foo], [echo ok], [echo oops])
1429 AS_VAR_IF([foo], [string], [echo oops]) && echo ok
1430 AS_VAR_PUSHDEF([tmp], [foo])
1431 AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
1432 '], [echo ok], [echo oops]) # 'font-lock
1433 AS_VAR_POPDEF([tmp])
1434 m4_ifdef([tmp], [echo oops])
1436 # Indirects via shell vars.
1439 AS_VAR_SET_IF([foo$num], [echo oops]) && echo ok
1440 AS_VAR_IF([foo$num], [], [echo ok], [echo oops])
1442 AS_VAR_SET_IF([foo$num], [echo ok])
1443 AS_VAR_SET([foo$num], ['\a "weird" `value` with; $fun '\''characters
1445 AS_VAR_COPY([bar], [foo$num])
1447 AS_VAR_COPY([foo$num], [bar])
1449 AS_ECHO(["AS_VAR_GET([foo$num])-"])
1450 AS_VAR_SET_IF([foo$num], [echo ok], [echo oops])
1451 AS_VAR_IF([foo$num], [string], [echo oops]) && echo ok
1452 AS_VAR_PUSHDEF([tmp], [foo$num])
1453 AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
1454 '], [echo ok], [echo oops]) # 'font-lock
1455 AS_VAR_POPDEF([tmp])
1456 m4_ifdef([tmp], [echo oops])
1458 # Indirects via command substitution.
1460 AS_VAR_SET_IF([`echo foo3`], [echo oops]) && echo ok
1461 AS_VAR_IF([`echo foo3`], [], [echo ok], [echo oops])
1463 AS_VAR_SET_IF([`echo foo3`], [echo ok])
1464 AS_VAR_SET([`echo foo3`], ['\a "weird" `value` with; $fun '\''characters
1466 AS_VAR_COPY([bar], [`echo foo3`])
1468 AS_VAR_COPY([`echo foo4`], [bar])
1470 AS_ECHO(["AS_VAR_GET([`echo foo4`])-"])
1471 AS_VAR_SET_IF([`echo foo4`], [echo ok], [echo oops])
1472 AS_VAR_IF([`echo foo4`], [string], [echo oops]) && echo ok
1473 AS_VAR_PUSHDEF([tmp], [`echo foo4`])
1474 AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
1475 '], [echo ok], [echo oops]) # 'font-lock
1476 AS_VAR_POPDEF([tmp])
1477 m4_ifdef([tmp], [echo oops])
1482 AT_CHECK([$CONFIG_SHELL ./script], [], [[ok
1485 \a "weird" `value` WITH; $fun 'characters
1487 \a "weird" `value` WITH; $fun 'characters
1496 \a "weird" `value` WITH; $fun 'characters
1498 \a "weird" `value` WITH; $fun 'characters-
1506 \a "weird" `value` WITH; $fun 'characters
1508 \a "weird" `value` WITH; $fun 'characters-
1517 ## --------------- ##
1518 ## AS_VAR_APPEND. ##
1519 ## --------------- ##
1521 AT_SETUP([AS@&t@_VAR_APPEND])
1522 AT_KEYWORDS([m4sh AS@&t@_VAR])
1524 AT_DATA_M4SH([script.as], [[dnl
1527 AS_VAR_APPEND([foo], ["hello, "])
1528 AS_VAR_APPEND([foo], [world])
1530 # Indirects via shell vars.
1532 AS_VAR_APPEND([foo$num], ['hello, '])
1533 AS_VAR_APPEND([foo$num], [`echo "world"`])
1535 # Indirects via command substitution.
1537 AS_VAR_APPEND([`echo foo2`], [${h}])
1538 AS_VAR_APPEND([`echo foo2`], ["$w"])
1543 AT_CHECK([$CONFIG_SHELL ./script], [],
1552 ## -------------- ##
1554 ## -------------- ##
1556 AT_SETUP([AS@&t@_VAR_ARITH])
1557 AT_KEYWORDS([m4sh AS@&t@_VAR])
1559 AT_DATA_M4SH([script.as], [[dnl
1562 AS_VAR_ARITH([foo], [1 + 1])
1564 # Indirects via shell vars.
1566 AS_VAR_ARITH([foo$num], [\( 2 + 3 \) \* 4])
1568 # Indirects via command substitution.
1569 AS_VAR_ARITH([`echo foo2`], [0 + -2 + $foo1 / 2])
1574 AT_CHECK([$CONFIG_SHELL ./script], [],
1583 ## ----------------- ##
1584 ## AS_INIT cleanup. ##
1585 ## ----------------- ##
1587 AT_SETUP([AS@&t@_INIT cleanup])
1588 AT_KEYWORDS([m4sh m4@&t@_wrap m4@&t@_wrap_lifo])
1590 AT_DATA_M4SH([script.as], [[dnl
1591 dnl Registered before AS_INIT's cleanups
1592 m4_wrap([echo cleanup 1
1594 m4_pushdef([_AS_SHELL_FN_SPY])dnl neutralize the spy, we don't care about it
1596 dnl Registered after AS_INIT's cleanups, thus goes to KILL diversion
1597 m4_wrap([echo cleanup 2
1598 dnl However, nested wraps and diversions can still be used
1599 dnl Also, test wrapping text that looks like parameter reference
1600 m4_wrap([echo cleanup 3
1601 m4_divert_text([M4SH-INIT], [m4_define([foo], [$1])dnl
1604 dnl Registered before AS_INIT's cleanups
1605 m4_wrap_lifo([echo cleanup 5
1611 AT_CHECK([$CONFIG_SHELL ./script], [], [[prep 4
1620 ## ------------------- ##
1621 ## AS_INIT_GENERATED. ##
1622 ## ------------------- ##
1624 AT_SETUP([AS@&t@_INIT_GENERATED])
1625 AT_KEYWORDS([AS@&t@_MESSAGE AS@&t@_MESSAGE_LOG_FD])
1627 dnl First run, no logging, tests shell selection
1628 AT_DATA_M4SH([script.as], [[dnl
1630 AS_INIT_GENERATED([child], [echo hello from child])
1632 AS_ECHO(["SHELL=$SHELL"])
1634 echo hello from parent
1635 AS_ECHO(["SHELL=$SHELL"])
1639 AT_CHECK([$CONFIG_SHELL ./script], [0], [stdout])
1640 AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore])
1641 sed s/parent/child/ <stdout >expout
1642 AT_CHECK([./child], [0], [expout])
1647 AT_CHECK([$CONFIG_SHELL ./script], [0], [expout])
1648 AT_CHECK([cmp child child.bak])
1649 AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore])
1650 sed s/parent/child/ <stdout >expout
1651 AT_CHECK([./child], [0], [expout])
1654 dnl Second run, with logging from parent and child, tests fd handling
1655 AT_DATA_M4SH([script.as], [[dnl
1658 m4_define([AS_MESSAGE_LOG_FD], [5])
1659 exec AS_MESSAGE_LOG_FD>log
1660 AS_INIT_GENERATED([$child], [echo hello1 from $child]) || AS_EXIT([1])
1662 m4_pushdef([AS_MESSAGE_LOG_FD])
1663 AS_MESSAGE([hello2 from ${child}child])
1664 m4_popdef([AS_MESSAGE_LOG_FD])
1665 exec AS_MESSAGE_LOG_FD>>log
1666 AS_MESSAGE([hello3 from child])
1668 AS_MESSAGE([hello from parent])
1669 dnl close log in parent before spawning child, for mingw
1670 exec AS_MESSAGE_LOG_FD>&-
1676 AT_CHECK([$CONFIG_SHELL ./script], [0], [[script: hello from parent
1678 child: hello2 from child
1679 child: hello3 from child
1681 AT_CHECK([[sed 's,:[0-9][0-9]*:,:0:,' log]], [0],
1682 [[script:0: hello from parent
1683 child:0: hello3 from child
1686 # Force write error creating a file on stdout
1687 if test -w /dev/full && test -c /dev/full; then
1688 AT_CHECK([$CONFIG_SHELL ./script /dev/full], [1], [ignore], [ignore])
1694 ## --------------- ##
1695 ## AS_MESSAGE_FD. ##
1696 ## --------------- ##
1698 AT_SETUP([AS@&t@_MESSAGE_FD])
1699 AT_KEYWORDS([AS@&t@_MESSAGE AS@&t@_MESSAGE_LOG_FD AS@&t_ORIGINAL_STDIN_FD])
1700 AT_KEYWORDS([AS@&t@_LINENO_PUSH])
1702 AT_DATA_M4SH([script.as], [[dnl
1704 m4_define([AS_ORIGINAL_STDIN_FD], [5])
1705 m4_define([AS_MESSAGE_LOG_FD], [6])
1706 m4_define([AS_MESSAGE_FD], [7])
1707 exec AS_ORIGINAL_STDIN_FD<&0 </dev/null AS_MESSAGE_LOG_FD>log
1708 if test $[#] -gt 0; then
1709 exec AS_MESSAGE_FD>/dev/null
1711 exec AS_MESSAGE_FD>&1
1713 AS_LINENO_PUSH([100])
1714 cat # tests that stdin is neutralized
1715 AS_MESSAGE([hello world])
1716 cat <&AS_ORIGINAL_STDIN_FD
1720 AT_CHECK([echo goodbye | $CONFIG_SHELL ./script], [0],
1721 [[script: hello world
1724 AT_CHECK([cat log], [0],
1725 [[script:100: hello world
1728 AT_CHECK([echo goodbye | $CONFIG_SHELL ./script silent], [0],
1731 AT_CHECK([cat log], [0],
1732 [[script:100: hello world
1738 ## --------------- ##
1739 ## _AS_CLEAN_DIR. ##
1740 ## --------------- ##
1742 AT_SETUP([_AS@&t@_CLEAN_DIR])
1744 dnl ensure that we can erase all files in a directory. Note that
1745 dnl _AS_CLEAN_DIR needs three globs to catch all these files.
1746 AT_DATA_M4SH([script.as], [[dnl
1748 # Unwritable subdirectories are common during 'make distcheck'.
1749 mkdir sub sub/unwritable || AS_ERROR([failed to mkdir])
1750 touch sub/unwritable/file || AS_ERROR([failed to touch])
1751 chmod a-wx sub/unwritable || AS_ERROR([failed to chmod])
1752 # Cygwin 1.5 can't touch 'sub/...', so make that file optional.
1753 touch sub/a sub/aa sub/aaa sub/.a sub/..a sub/.aa \
1754 || AS_ERROR([failed to touch])
1755 touch sub/... 2>/dev/null
1756 _AS_CLEAN_DIR([sub]) || AS_ERROR([failed to clean])
1757 # rmdir instead of 'rm -fr' here proves that we emptied sub.
1758 rmdir sub || AS_ERROR([failed to rmdir])
1762 AT_CHECK([$CONFIG_SHELL ./script])
1773 AT_DATA_M4SH([script.as], [[dnl
1781 AT_CHECK([$CONFIG_SHELL ./script], [], [foobar