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 ## ---------------- ##
23 ## ---------------- ##
28 # We cannot unset LINENO with Zsh, yet this test case relies on
29 # unsetting LINENO to compare its result when (i) LINENO is supported
30 # and when (ii) it is not.
31 # So just skip if the shell is ZSH.
32 AT_CHECK([test -n "${ZSH_VERSION+set}" && exit 77], ignore)
34 # AT_DATA_LINENO(FILE-NAME,
35 # UNSET-LINENO = true | false, COUNTER, COUNTER-RE)
36 # ----------------------------------------------------------------
37 # Produce the FILE-NAME M4sh script which uses the COUNTER LINENO or
38 # _oline_, which we can recognized via COUNTER-RE. Unset LINENO is
41 # Use COUNTER, COUNTER-RE = [__LINENO__], [LINENO]
42 # or = [__OLINE__], [_oline__]
44 # instead of the obvious $LINENO and __oline__, because they would
45 # be replaced in the test suite itself, even before creating these
46 # scripts. For the same reason, grep for LINENO and _oline__ (sic).
48 # UNSET-LINENO is a shell condition to make sure the scripts have the
49 # same number of lines in the output, so that their outputs be identical.
50 m4_define([AT_DATA_LINENO],
53 m4@&t@_divert_text([], [
55 AS@&t@_UNSET([LINENO])
60 grep 'Line: .*$4' "$[0]" >/dev/null ||
61 AS@&t@_ERROR([cannot find original script])
64 # If occurrences of $LINENO or __@&t@oline__ were wanted, create them.
65 sed 's/__LINENO__/$''LINENO/g;s/__OLINE__/__''oline__/g' $1.tas >$1.as
66 AT_CHECK([autom4te -l m4sh $1.as -o $1])
69 # `_oline_', once processed and ran, produces our reference.
70 # We check that we find ourselves by looking at a string which is
71 # available only in the original script: `_oline_'.
72 AT_DATA_LINENO([reference], [false], [__OLINE__], [_oline__])
73 AT_CHECK([./reference], 0, [stdout])
78 # Now using a maybe-functioning LINENO, with different call conventions.
79 # Be sure to be out of the PATH.
80 AT_CHECK([mkdir test || exit 77])
82 AT_DATA_LINENO([test/test-1], [false], [__LINENO__], [LINENO])
83 AT_CHECK([./test/test-1], 0, [expout])
84 AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-1)],
86 AT_CHECK([sh ./test/test-1], 0, [expout])
88 # Now using a disabled LINENO, with different call conventions.
89 AT_DATA_LINENO([test/test-2], [true], [__LINENO__], [LINENO])
90 AT_CHECK([./test/test-2], 0, [expout])
91 AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-2)],
93 AT_CHECK([sh ./test/test-2], 0, [expout])
99 ## ---------------------- ##
100 ## LINENO stack support. ##
101 ## ---------------------- ##
103 AT_SETUP([LINENO stack])
106 AT_DATA_M4SH([script.as],
109 AS_LINENO_PUSH([9999])
110 test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1])
111 AS_LINENO_PUSH([8888])
112 test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 2])
114 test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1])
116 test x${as_lineno+set} = xset && AS_ERROR([as_lineno set at depth 0])
122 AT_CHECK([$CONFIG_SHELL ./script])
131 # Output a framed one-line message.
132 AT_SETUP([AS@&t@_BOX])
135 AT_DATA_M4SH([script.as],
138 AS_BOX([Send a simple message, to foobar@example.com])
139 AS_BOX([Send a simple message, to foobar@example.com], [$])
140 m4_define([msg], [$complex])
141 complex='Not quite as simple |$[1]'
148 AT_CHECK([sed -n '/ -\{44\} /,/ -\{44\} /p' script ]dnl
149 [| sed '1 s/.*## -/## -/; 3 s/- ##.*/- ##/'], [],
150 [[## -------------------------------------------- ##
151 ## Send a simple message, to foobar@example.com ##
152 ## -------------------------------------------- ##
155 AT_CHECK([$CONFIG_SHELL ./script], [], [[
156 ## -------------------------------------------- ##
157 ## Send a simple message, to foobar@example.com ##
158 ## -------------------------------------------- ##
159 ## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
160 ## Send a simple message, to foobar@example.com ##
161 ## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
162 ## ----------------------- ##
163 ## Not quite as simple |$1 ##
164 ## ----------------------- ##
165 ## ,,,,,,,,,,,,,,,,,,,,,,, ##
166 ## Not quite as simple |$1 ##
167 ## ,,,,,,,,,,,,,,,,,,,,,,, ##
173 # Strip path from file.
174 AT_SETUP([AS@&t@_BASENAME])
177 AT_DATA_M4SH([script.as],
180 m4_define([BASENAME_TEST],
181 [base=`AS_BASENAME([$1])`
182 test "$base" = "$2" ||
183 echo "basename($1) = $base instead of $2" >&2
185 base=`_AS_BASENAME_SED([$1])`
186 test "$base" = "$2" ||
187 echo "basename_sed($1) = $base instead of $2" >&2])
189 BASENAME_TEST([//1], [1])
190 BASENAME_TEST([/1], [1])
191 BASENAME_TEST([./1], [1])
192 BASENAME_TEST([../../2], [2])
193 BASENAME_TEST([//1/], [1])
194 BASENAME_TEST([/1/], [1])
195 BASENAME_TEST([./1/], [1])
196 BASENAME_TEST([../../2], [2])
197 BASENAME_TEST([//1/3], [3])
198 BASENAME_TEST([/1/3], [3])
199 BASENAME_TEST([./1/3], [3])
200 BASENAME_TEST([../../2/3], [3])
201 BASENAME_TEST([//1/3///], [3])
202 BASENAME_TEST([/1/3///], [3])
203 BASENAME_TEST([./1/3///], [3])
204 BASENAME_TEST([../../2/3///], [3])
205 BASENAME_TEST([//1//3/], [3])
206 BASENAME_TEST([/1//3/], [3])
207 BASENAME_TEST([./1//3/], [3])
208 BASENAME_TEST([a.c], [a.c])
209 BASENAME_TEST([a.c/], [a.c])
210 BASENAME_TEST([/a.c/], [a.c])
211 BASENAME_TEST([/1/a.c], [a.c])
212 BASENAME_TEST([/1/a.c/], [a.c])
213 BASENAME_TEST([/1/../a.c], [a.c])
214 BASENAME_TEST([/1/../a.c/], [a.c])
215 BASENAME_TEST([./1/a.c], [a.c])
216 BASENAME_TEST([./1/a.c/], [a.c])
221 AT_CHECK([$CONFIG_SHELL ./script])
230 # Strip filename component.
231 AT_SETUP([AS@&t@_DIRNAME])
234 AT_DATA_M4SH([script.as],
237 # The EXPR variant is allowed to fail if `expr' was considered as too
238 # weak for us, in which case `as_expr=false'.
239 m4_define([DIRNAME_TEST],
240 [dir=`AS_DIRNAME([$1])`
241 test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
242 echo "dirname($1) = $dir instead of $2" >&2
244 if test "$as_expr" != false; then
245 dir=`_AS_DIRNAME_EXPR([$1])`
246 test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
247 echo "dirname_expr($1) = $dir instead of $2" >&2
250 dir=`_AS_DIRNAME_SED([$1])`
251 test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
252 echo "dirname_sed($1) = $dir instead of $2" >&2])
254 DIRNAME_TEST([/], [/])
255 DIRNAME_TEST([//], [//], [/])
256 DIRNAME_TEST([///], [/])
257 DIRNAME_TEST([//1], [//], [/])
258 DIRNAME_TEST([/1], [/])
259 DIRNAME_TEST([./1], [.])
260 DIRNAME_TEST([../../2], [../..])
261 DIRNAME_TEST([//1/], [//], [/])
262 DIRNAME_TEST([/1/], [/])
263 DIRNAME_TEST([./1/], [.])
264 DIRNAME_TEST([../../2], [../..])
265 DIRNAME_TEST([//1/3], [//1])
266 DIRNAME_TEST([/1/3], [/1])
267 DIRNAME_TEST([./1/3], [./1])
268 DIRNAME_TEST([../../2/3], [../../2])
269 DIRNAME_TEST([//1/3///], [//1])
270 DIRNAME_TEST([/1/3///], [/1])
271 DIRNAME_TEST([./1/3///], [./1])
272 DIRNAME_TEST([../../2/3///], [../../2])
273 DIRNAME_TEST([//1//3/], [//1])
274 DIRNAME_TEST([/1//3/], [/1])
275 DIRNAME_TEST([./1//3/], [./1])
276 DIRNAME_TEST([../../2//3/], [../../2])
281 AT_CHECK([$CONFIG_SHELL ./script])
286 ## ---------------- ##
287 ## AS_SET_CATFILE. ##
288 ## ---------------- ##
290 AT_SETUP([AS@&t@_SET_CATFILE])
293 AT_DATA_M4SH([script.as],
296 # CATFILE_TEST(DIR, FILE, EXPECTED)
297 m4_define([CATFILE_TEST],
298 [# AS_SET_CATFILE works and can be used in a compound list.
299 if AS_SET_CATFILE([var], [$1], [$2]) \
300 && test "$var" = $3; then :; else
301 echo "catfile($1, $2) = $var != $3" >&2
303 # AS_SET_CATFILE can use non-literals in its arguments.
307 if AS_SET_CATFILE([$varname], [$dirpart], [$filepart]) \
308 && test "$var2" = $3; then :; else
309 echo "catfile($dirpart, $filepart) = $var2 != $3" >&2
313 CATFILE_TEST([dir], [file], [dir/file])
314 CATFILE_TEST([.], [file], [file])
315 CATFILE_TEST([dir], [.], [dir])
316 CATFILE_TEST([dir], [/abs/file], [/abs/file])
317 CATFILE_TEST([dir], [C:/abs/file], [C:/abs/file])
318 CATFILE_TEST(["dir name"], ['file name'], ['dir name/file name'])
324 AT_CHECK([$CONFIG_SHELL ./script])
333 # Print literal strings, with/without newline.
334 AT_SETUP([AS@&t@_ECHO and AS@&t@_ECHO_N])
337 AT_DATA_M4SH([script.as],
340 m4_define([ECHO_TEST],
341 [echo=`AS_ECHO(['$1'])`
342 test "X$echo" = 'X$1' ||
343 echo "AS@&t@_ECHO('"'$1'"') outputs '$echo'" >&2
345 echo=`AS_ECHO_N(['$1'])`
346 test "X$echo" = 'X$1' ||
347 echo "AS@&t@_ECHO_N('"'$1'"') outputs '$echo'" >&2])
351 ECHO_TEST([---...---])
360 ECHO_TEST([\a\b\c\f\n\r\t\v\"\])
372 AT_CHECK([$CONFIG_SHELL ./script])
382 # Exit scripts with given status.
383 AT_SETUP([AS@&t@_EXIT])
384 AT_KEYWORDS([m4sh AS@&t@_SET_STATUS])
386 AT_DATA_M4SH([script.as],
388 test x${1} = xa && AS_EXIT
389 test x${1} = xb && AS_EXIT([${2}])
390 test x${1} = xc && { AS_SET_STATUS([${2}]); AS_EXIT; }
391 test x${1} = xd && trap 's=$?; echo $s; AS_EXIT([$s])' 0
392 test x${2} = xe && set -e
393 test $[#] -gt 0 || AS_EXIT
395 dnl Solaris /bin/sh 'set -e' doesn't react to failed function calls
397 && { echo 'skipping rest of test: set -e support is lousy'; exit 77; }
402 AT_CHECK([$CONFIG_SHELL ./script], [1])
403 AT_CHECK([$CONFIG_SHELL ./script ''], [4])
404 AT_CHECK([$CONFIG_SHELL ./script a], [0])
405 AT_CHECK([$CONFIG_SHELL ./script b], [0])
406 AT_CHECK([$CONFIG_SHELL ./script b 0], [0])
407 AT_CHECK([$CONFIG_SHELL ./script b 2], [2])
408 AT_CHECK([$CONFIG_SHELL ./script c 0], [0])
409 AT_CHECK([$CONFIG_SHELL ./script c 2], [2])
410 AT_CHECK([$CONFIG_SHELL ./script d], [4], [[4
412 dnl If we got to this point without a FAIL, then AS_EXIT at least works.
413 dnl The rest of this test relies on semi-decent 'set -e' support, even
414 dnl though m4sh in general should not try to rely on it because of
415 dnl portability nightmares on what constructs are considered errors across
416 dnl various shells; therefore, an overall SKIP result is desirable on
417 dnl broken shells like Solaris /bin/sh.
418 AT_CHECK([$CONFIG_SHELL ./script '' e], [3])
419 AT_CHECK([$CONFIG_SHELL ./script d e], [3], [stdout])
420 dnl NetBSD sh fails to output on stderr here.
421 AT_CHECK([grep 3 stdout || exit 77], [], [ignore])
432 AT_SETUP([AS@&t@_MKDIR_P])
435 AT_DATA_M4SH([script.as],
441 AS_MKDIR_P(["$pwd/1/2/3/4/5/6"])
442 test -d "$pwd/1/2/3/4/5/6" ||
443 AS_ERROR([$pwd/1/2/3/4/5/6 has not been properly created])
445 AS_MKDIR_P(["a/b/c/d/e/f"])
446 test -d a/b/c/d/e/f ||
447 AS_ERROR([a/b/c/d/e/f has not been properly created])
452 AT_CHECK([$CONFIG_SHELL ./script])
459 ## -------------------- ##
460 ## AS_VERSION_COMPARE. ##
461 ## -------------------- ##
463 # Three-way version comparison.
464 AT_SETUP([AS@&t@_VERSION_COMPARE])
467 AT_DATA_M4SH([script.as],
470 m4_define([VERSION_COMPARE_TEST],
471 [AS_VERSION_COMPARE([$1], [$3], [result='<'], [result='='], [result='>'])
472 test "X$result" = "X$2" ||
473 AS_ERROR([version $1 $result $3; should be $1 $2 $3])
475 [AS_VERSION_COMPARE([$3], [$1], [result='<'], [result='='], [result='>'])
476 test "X$result" = "X>" ||
477 AS_ERROR([version $3 $result $1; should be $3 > $1])])])
479 VERSION_COMPARE_TEST([], =, [])
480 VERSION_COMPARE_TEST([1.0], =, [1.0])
481 VERSION_COMPARE_TEST([alpha-1.0], =, [alpha-1.0])
483 # These tests are taken from libc/string/tst-svc.expect.
485 000 001 00 00a 01 01a 0 0a 2.8 2.8-0.4 20 21 22 212 CP037 CP345 CP1257
486 foo foo-0.4 foo-0.4a foo-0.4b foo-0.5 foo-0.10.5 foo-3.01 foo-3.0
487 foo-3.0.0 foo-3.0.1 foo-3.2 foo-3.10 foo00 foo0
490 for test2 in $tst_svc_expect; do
491 VERSION_COMPARE_TEST([$test1], <, [$test2])
499 AT_CHECK([$CONFIG_SHELL ./script])
513 AT_DATA_M4SH([script.as],
516 test "$as_me" = script || AS_ECHO([["incorrect value of \$as_me: $as_me"]])
520 AT_CHECK([$CONFIG_SHELL ./script])
527 ## ----------------------------- ##
528 ## Negated classes in globbing. ##
529 ## ----------------------------- ##
531 # According to http://www.in-ulm.de/~mascheck/bourne/, all shells with
532 # functions also support `[!...]'. But `[^...]' is not universally supported.
534 AT_SETUP([Negated classes in globbing])
537 AT_DATA_M4SH([script.as],
540 case 'with!two!bangs' in
542 *) AS_ERROR([[`*[!a-z]*' didn't match `with!two!bangs']]);;
546 *[[!a-z]]*) AS_ERROR([[`*[!a-z]*' matched `without']]);;
551 AT_CHECK([$CONFIG_SHELL ./script])
558 ## ------------------- ##
559 ## Functions Support. ##
560 ## ------------------- ##
562 # All m4sh scripts require function support.
564 AT_SETUP([Functions Support])
567 AT_DATA_M4SH([script.as],
583 if func_success; then
584 if func_failure; then
585 AS_ERROR([func_failure passed])
588 AS_ERROR([func_success failed])
593 AT_CHECK([$CONFIG_SHELL ./script])
600 ## ------------------------------ ##
601 ## Functions and return Support. ##
602 ## ------------------------------ ##
604 # All m4sh scripts require working return within functions.
606 AT_SETUP([Functions and return Support])
609 AT_DATA_M4SH([script.as],
621 if func_success; then
622 if func_failure; then
623 AS_ERROR([func_failure passed])
626 AS_ERROR([func_success failed])
631 AT_CHECK([$CONFIG_SHELL ./script])
636 ## --------------------------- ##
637 ## Nested AS_REQUIRE_SHELL_FN. ##
638 ## --------------------------- ##
640 # Hypothesis: M4sh expands nested AS_REQUIRE_SHELL_FN
643 AT_SETUP([Nested AS@&t@_REQUIRE_SHELL_FN])
646 AT_DATA_M4SH([script.as], [[dnl
647 m4_define([INIT], [oops])dnl
650 m4_defun([TEST_FUNC2_BODY], [
654 m4_defun([TEST_FUNC1_BODY], [
655 AS_REQUIRE_SHELL_FN([test_func2], [], [TEST_FUNC2_BODY])
659 AS_REQUIRE_SHELL_FN([test_func1], [], [TEST_FUNC1_BODY])
664 AT_CHECK([$CONFIG_SHELL ./script])
669 ## ------------------- ##
670 ## Nested AS_REQUIRE. ##
671 ## ------------------- ##
673 # Hypothesis: M4sh expands the requirements of AS_REQUIRE in the
674 # requested diversion, even if other AS_REQUIREs are interleaved.
676 AT_SETUP([Nested AS@&t@_REQUIRE])
679 AT_DATA_M4SH([script.as], [[dnl
682 m4_defun([in_fn_diversion], still_in_m4sh_init_fn=yes)
683 m4_defun([not_in_fn_diversion], still_in_m4sh_init_fn=no)
685 m4_defun([NESTED], [nested_require_in_fn_diversion=$still_in_m4sh_init_fn])
687 m4_defun([OUTER], [AS_REQUIRE([NESTED])dnl
688 outer_require_in_fn_diversion=$still_in_m4sh_init_fn])
690 m4_defun([test_init], [
691 AS_REQUIRE([in_fn_diversion], , [M4SH-INIT-FN])
692 AS_REQUIRE([OUTER], , [M4SH-INIT-FN])
693 AS_REQUIRE([not_in_fn_diversion], , [M4SH-INIT-FN])
697 if test $outer_require_in_fn_diversion != yes; then AS_EXIT([1]); fi
698 if test $nested_require_in_fn_diversion != no; then AS_EXIT([1]); fi
702 AT_CHECK([$CONFIG_SHELL ./script])
707 ## ------------------------------------ ##
708 ## AS_REQUIRE_SHELL_FN and m4_require. ##
709 ## ------------------------------------ ##
711 # Hypothesis: M4sh expands the requirements of AS_REQUIRE_SHELL_FN
712 # in M4SH-INIT-FN. This changed after Autoconf 2.63.
714 AT_SETUP([AS@&t@_REQUIRE_SHELL_FN and m4@&t@_require])
717 AT_DATA_M4SH([script.as], [[dnl
720 m4_defun([in_m4_sh_init], still_in_m4sh_init=yes)
721 m4_defun([not_in_m4_sh_init], still_in_m4sh_init=no)
723 m4_defun([error_if_emitted_in_m4sh_init], [
724 if test x$still_in_m4sh_init = xyes; then
725 AS_ERROR([requirement emitted in M4SH-INIT])
729 m4_defun([TEST_FUNC_BODY], [
730 m4_require([error_if_emitted_in_m4sh_init])
731 : echo in shell function, with parameter = [$]1
735 m4_defun([test_init], [
736 AS_REQUIRE([in_m4_sh_init], , [M4SH-INIT-FN])
737 AS_REQUIRE_SHELL_FN([test_func], [], [TEST_FUNC_BODY])
738 AS_REQUIRE([not_in_m4_sh_init])
746 AT_CHECK([$CONFIG_SHELL ./script])
755 AT_SETUP([AS@&t@_HELP_STRING])
756 AT_KEYWORDS([m4sh m4@&t@_text_wrap m4@&t@_expand])
758 AT_DATA_M4SH([script.as],
761 echo "AS_HELP_STRING([--an-option],[some text])"
762 echo "AS_HELP_STRING([--another-much-longer-option],
763 [some other text which should wrap at our default of 80 characters.])"
764 echo "AS_HELP_STRING([--fooT=barT], [foo bar])"
765 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@], [foo bar])"
766 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789], [foo bar])"
767 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890], [foo bar])"
768 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901], [foo bar])"
769 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012], [foo bar])"
770 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123], [foo bar])"
771 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
772 [some other text which should wrap at our default of 80 characters.])"
773 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
774 [some other text which should wrap at our default of 80 characters.])"
775 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
776 [some other text which should wrap at our default of 80 characters.])"
777 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
778 [some other text which should wrap at our default of 80 characters.])"
779 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
780 [some other text which should wrap at our default of 80 characters.])"
781 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
782 [some other text which should wrap at our default of 80 characters.])"
783 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
784 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
785 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
786 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
787 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
788 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
789 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
790 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
791 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
792 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
793 echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
794 [some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
795 echo "AS_HELP_STRING([[--foo[=bar]]],
796 [some other t[]t which should wrap at our default of 80 characters.])"
797 echo "AS_HELP_STRING([[--foo[=bar]123456789]],
798 [some other t[]t which should wrap at our default of 80 characters.])"
799 echo "AS_HELP_STRING([[--foo[=bar]1234567890]],
800 [some other t[]t which should wrap at our default of 80 characters.])"
801 echo "AS_HELP_STRING([[--foo[=bar]12345678901]],
802 [some other t[]t which should wrap at our default of 80 characters.])"
803 echo "AS_HELP_STRING([[--foo[=bar]123456789012]],
804 [some other t[]t which should wrap at our default of 80 characters.])"
805 echo "AS_HELP_STRING([[--foo[=bar]1234567890123]],
806 [some other t[]t which should wrap at our default of 80 characters.])"
807 m4_define([mac], [MACRO])dnl
808 echo "AS_HELP_STRING([--mac], [mac])"
809 echo "AS_HELP_STRING([--o1, --o2], [two
810 options, one description])"
811 echo "AS_HELP_STRING([[[--o3, --o4]]], [comma inside literal quoting])"
812 echo "AS_HELP_STRING([--tune1], [check out the tuned formatting],
814 echo "AS_HELP_STRING([--tune2], [check out the tuned formatting],
816 echo "AS_HELP_STRING([--tune3], [check out the tuned formatting],
818 echo "AS_HELP_STRING([--tune4], [check out the tuned formatting],
823 AT_CHECK([$CONFIG_SHELL ./script], [0],
824 [[ --an-option some text
825 --another-much-longer-option
826 some other text which should wrap at our default of
830 --foo[=bar]123456789 foo bar
831 --foo[=bar]1234567890 foo bar
832 --foo[=bar]12345678901 foo bar
833 --foo[=bar]123456789012 foo bar
834 --foo[=bar]1234567890123
836 --foo[=bar] some other text which should wrap at our default of
838 --foo[=bar]123456789 some other text which should wrap at our default of
840 --foo[=bar]1234567890 some other text which should wrap at our default of
842 --foo[=bar]12345678901 some other text which should wrap at our default of
844 --foo[=bar]123456789012 some other text which should wrap at our default of
846 --foo[=bar]1234567890123
847 some other text which should wrap at our default of
849 --foo[=bar] some other [ex] which should wrap at our default of
851 --foo[=bar]123456789 some other [ex] which should wrap at our default of
853 --foo[=bar]1234567890 some other [ex] which should wrap at our default of
855 --foo[=bar]12345678901 some other [ex] which should wrap at our default of
857 --foo[=bar]123456789012 some other [ex] which should wrap at our default of
859 --foo[=bar]1234567890123
860 some other [ex] which should wrap at our default of
862 --foo[=bar] some other t[]t which should wrap at our default of
864 --foo[=bar]123456789 some other t[]t which should wrap at our default of
866 --foo[=bar]1234567890 some other t[]t which should wrap at our default of
868 --foo[=bar]12345678901 some other t[]t which should wrap at our default of
870 --foo[=bar]123456789012 some other t[]t which should wrap at our default of
872 --foo[=bar]1234567890123
873 some other t[]t which should wrap at our default of
876 --o1, --o2 two options, one description
877 [--o3, --o4] comma inside literal quoting
878 --tune1 check out the tuned formatting
879 --tune2 check out the tuned formatting
880 --tune3 check out the
883 --tune4 check out the tuned
890 ## ------------------- ##
891 ## AS_IF and AS_CASE. ##
892 ## ------------------- ##
894 AT_SETUP([AS@&t@_IF and AS@&t@_CASE])
895 AT_KEYWORDS([m4sh m4@&t@_map_args_pair])
897 AT_DATA_M4SH([script.as], [[dnl
899 # Syntax checks: cope with empty arguments.
900 AS_IF([:], [], [echo wrong])
901 AS_IF([:], [echo one], [echo wrong])
902 AS_IF([false], [echo wrong], [echo two])
903 AS_IF([false], [echo wrong])
905 AS_IF([false], [echo wrong],
907 AS_IF([false], [echo wrong],
910 AS_IF([false], [echo wrong],
911 [false], [echo wrong])
912 AS_IF([false], [echo wrong],
913 [false], [echo wrong],
915 AS_IF([false], [echo wrong],
916 [false], [echo wrong],
920 AS_CASE([foo], [echo seven])
932 # check for nesting, lists, and side effects, and quoting robustness
934 AS_IF([AS_IF([$empty], [echo eleven])]) && AS_CASE([foo]) && echo twelve
936 AS_IF([touch file; false]) && echo thirteen
937 test -f file && echo fourteen
939 AS_CASE([`touch file; false`]) && test -f file && echo fifteen
940 dnl The next line is badly underquoted; don't intentionally copy this style.
941 AS_CASE([foo], [foo], m4_do(AS_CASE([bar], [bar], [echo sixteen])))
942 dnl Handle blank arguments.
943 AS_IF([false], [:], [ ]) && AS_CASE([foo], [foo], []
945 m4_define([empty])AS_IF([:], [empty]
946 ) && AS_CASE([foo], [foo], [empty]) && echo eighteen
947 dnl We can't handle AS_IF([false], [:], [empty]) unless m4_expand is
948 dnl taught how to handle m4_require. The user is responsible for
949 dnl avoiding the syntax error in that case.
951 # check that require works correctly
952 m4_for([n], 1, 9, [],
953 [m4_defun([FOO]n, [foo]n[=]n)dnl
955 [m4_require([FOO]]n[)dnl
960 echo "foo1=$foo1 bar1=$bar1"
961 AS_IF([:], [], [BAR2])
962 echo "foo2=$foo2 bar2=$bar2"
963 AS_IF([false], [BAR3])
964 echo "foo3=$foo3 bar3=$bar3"
965 AS_IF([false], [], [BAR4])
966 echo "foo4=$foo4 bar4=$bar4"
967 AS_CASE([x], [x], [BAR5])
968 echo "foo5=$foo5 bar5=$bar5"
969 AS_CASE([x], [y], [BAR6])
970 echo "foo6=$foo6 bar6=$bar6"
974 echo "foo7=$foo7 bar7=$bar7"
978 echo "foo8=$foo8 bar8=$bar8"
982 echo "foo9=$foo9 bar9=$bar9"
986 AT_CHECK([$CONFIG_SHELL ./script], [0], [[one
1015 dnl stress test for large number of conditionals
1016 dnl too large, and we start tickling shell bugs
1017 m4_pushdef([limit], [1000])dnl
1018 AT_DATA_M4SH([script.as], [[dnl
1020 AS_IF(m4_shift(m4_for([i], [1], ]limit[, [], [, test $[1] = i, echo i])))
1021 AS_IF(m4_shift(m4_for([i], [1], ]limit[, [], [, test $[1] = i, echo i])),
1023 AS_CASE([$[1]]m4_for([i], [1], ]limit[, [], [, i, echo i]))
1024 AS_CASE([$[1]]m4_for([i], [1], ]limit[, [], [, i, echo i]), [echo default])
1027 dnl Add --force so autom4te doesn't think `script' is still up to date.
1028 AT_CHECK_M4SH([--force])
1029 AT_CHECK([$CONFIG_SHELL ./script 1], [0], [[1
1034 AT_CHECK([$CONFIG_SHELL ./script limit], [0], [limit
1039 AT_CHECK([$CONFIG_SHELL ./script default], [0], [[default
1051 AT_SETUP([AS@&t@_FOR])
1054 AT_DATA_M4SH([script.as], [[dnl
1058 AS_FOR([m4var], [shvar], [a],
1059 [echo "m4var $shvar"])
1060 AS_FOR([m4var], [shvar], [b c],
1061 [echo "m4var $shvar"])
1063 AS_FOR([m4var], [shvar], [$list],
1064 [echo "m4var $shvar"])
1065 AS_FOR([m4var], [shvar], ["$list"],
1066 [echo "m4var $shvar"])
1067 AS_FOR([m4var], [shvar], ['$list'],
1068 [echo "m4var $shvar"])
1069 AS_FOR([m4var], [shvar], [\'],
1070 [echo "m4var $shvar"])
1072 # Syntax checks: cope with empty/blank arguments.
1074 AS_FOR([], [shvar], [],
1075 [echo "m4_defn([]) $shvar"])
1077 AS_FOR([], [shvar], [`touch file`])
1078 test -f file || exit 1
1079 AS_FOR([], [shvar], [], [ ])
1080 m4_define([empty])AS_FOR([], [shvar], [], [empty])
1082 # Check that break works.
1085 AS_FOR([m4var], [shvar], [h i],
1086 [echo "m4var"; break 2])
1091 AS_FOR([m4var], [shvar], [j],
1092 [echo "m4var"; break 2])
1098 AT_CHECK([$CONFIG_SHELL ./script], [0], [[a a
1115 ## --------------- ##
1116 ## AS_LITERAL_IF. ##
1117 ## --------------- ##
1119 AT_SETUP([AS@&t@_LITERAL_IF])
1120 AT_KEYWORDS([m4sh AS@&t@_LITERAL_WORD_IF AS@&t@_LITERAL_HEREDOC_IF])
1122 AT_DATA_M4SH([script.as], [[dnl
1124 echo AS_LITERAL_IF([lit], [ok], [ERR]) 1
1125 echo AS_LITERAL_IF([l-/.it], [ok], [ERR]) 2
1126 echo AS_LITERAL_IF([l''it], [ERR], [ok]) 3
1127 echo AS_LITERAL_IF([l$it], [ERR], [ok]) 4
1128 echo AS_LITERAL_IF([l$it], [ERR1], [ERR2], [ok]) 5
1129 echo AS_LITERAL_IF([l${it}], [ERR1], [ERR2], [ok]) 6
1130 echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR], [ok]) 7
1131 echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR1], [ok], [ERR2]) 8
1132 m4_define([mac], [l-/.it])
1133 echo AS_LITERAL_IF([mac], [ok], [ERR]) 9
1134 echo AS_LITERAL_IF([mac($, ``)], [ok], [ERR]) 10
1135 m4_define([mac], [l$it])
1136 echo AS_LITERAL_IF([mac], [ERR], [ok]) 11
1137 echo AS_LITERAL_IF([mac], [ERR1], [ERR2], [ok]) 12
1138 m4_define([mac], [l``it])
1139 echo AS_LITERAL_IF([mac], [ERR], [ok]) 13
1140 echo AS_LITERAL_IF([mac], [ERR1], [ok], [ERR2]) 14
1141 echo AS_LITERAL_IF([ a ][
1143 echo AS_LITERAL_WORD_IF([ a ][
1145 echo AS_LITERAL_HEREDOC_IF([ a ][
1147 echo AS_LITERAL_IF([(a)], [ERR], [ok]) 18
1148 echo AS_LITERAL_WORD_IF([(a)], [ERR], [ok]) 19
1149 echo AS_LITERAL_HEREDOC_IF([(a)], [ok], [ERR]) 20
1150 echo AS_LITERAL_IF([@S|@a], [ERR], [ok]) 21
1151 echo AS_LITERAL_WORD_IF([@S|@a], [ERR], [ok]) 22
1152 echo AS_LITERAL_HEREDOC_IF([@S|@a], [ERR], [ok]) 23
1156 AT_CHECK([$CONFIG_SHELL ./script], [],
1185 ## --------------------- ##
1186 ## AS_TR_SH, AS_TR_CPP. ##
1187 ## --------------------- ##
1189 AT_SETUP([AS@&t@_TR_SH and AS@&t@_TR_CPP])
1191 AT_DATA_M4SH([script.as], [[dnl
1193 m4_define([abc], [hI])m4_define([ABC], [Hi])
1194 m4_define([hi], [oops])m4_define([HI], [OOPS])
1195 echo AS_TR_SH(abc) AS_TR_SH(aBc) AS_TR_SH(ABC)
1196 echo AS_TR_SH([abc]) AS_TR_SH([aBc]) AS_TR_SH([ABC])
1197 echo AS_TR_SH([[abc]]) AS_TR_SH([[aBc]]) AS_TR_SH([[ABC]])
1198 echo AS_TR_CPP(abc) AS_TR_CPP(aBc) AS_TR_CPP(ABC)
1199 echo AS_TR_CPP([abc]) AS_TR_CPP([aBc]) AS_TR_CPP([ABC])
1200 echo AS_TR_CPP([[abc]]) AS_TR_CPP([[aBc]]) AS_TR_CPP([[ABC]])
1202 [var=abc vAr=aBc VAR=ABC]
1203 echo AS_TR_SH($var) AS_TR_SH($vAr) AS_TR_SH($VAR)
1204 echo AS_TR_SH([$var]) AS_TR_SH([$vAr]) AS_TR_SH([$VAR])
1205 echo AS_TR_SH([[$var]]) AS_TR_SH([[$vAr]]) AS_TR_SH([[$VAR]])
1206 echo AS_TR_CPP($var) AS_TR_CPP($vAr) AS_TR_CPP($VAR)
1207 echo AS_TR_CPP([$var]) AS_TR_CPP([$vAr]) AS_TR_CPP([$VAR])
1208 echo AS_TR_CPP([[$var]]) AS_TR_CPP([[$vAr]]) AS_TR_CPP([[$VAR]])
1210 echo AS_TR_SH(`echo abc`) AS_TR_SH(`echo aBc`) AS_TR_SH(`echo ABC`)
1211 echo AS_TR_SH([`echo abc`]) AS_TR_SH([`echo aBc`]) AS_TR_SH([`echo ABC`])
1212 echo AS_TR_SH([[`echo abc`]]) AS_TR_SH([[`echo aBc`]]) AS_TR_SH([[`echo ABC`]])
1213 echo AS_TR_CPP(`echo abc`) AS_TR_CPP(`echo aBc`) AS_TR_CPP(`echo ABC`)
1214 echo AS_TR_CPP([`echo abc`]) AS_TR_CPP([`echo aBc`]) AS_TR_CPP([`echo ABC`])
1215 echo AS_TR_CPP([[`echo abc`]]) AS_TR_CPP([[`echo aBc`]]) AS_TR_CPP([[`echo ABC`]])
1217 echo AS_TR_SH([a.b/c+*-])
1218 echo AS_TR_CPP([a.b/c+*-])
1220 echo AS_TR_SH([$var])
1221 echo AS_TR_CPP([$var])
1222 m4_define([macro], [a.b/c+*-])
1223 echo AS_TR_SH([macro])
1224 echo AS_TR_CPP([macro])
1228 AT_CHECK([$CONFIG_SHELL ./script], [],
1265 AT_SETUP([AS@&t@_VAR basics])
1266 AT_KEYWORDS([m4sh AS@&t@_VAR_COPY AS@&t@_VAR_SET AS@&t@_VAR_GET])
1267 AT_KEYWORDS([AS@&t@_VAR_TEST_SET AS@&t@_VAR_SET_IF AS@&t@_VAR_IF])
1268 AT_KEYWORDS([AS@&t@_VAR_PUSHDEF AS@&t@_VAR_POPDEF])
1270 AT_DATA_M4SH([script.as], [[dnl
1272 m4_define([with], [WITH])
1274 dnl AS_VAR_SET_IF also covers AS_VAR_TEST_SET
1275 AS_VAR_SET_IF([foo], [echo oops]) && echo ok
1276 AS_VAR_IF([foo], [], [echo ok], [echo oops])
1278 AS_VAR_SET_IF([foo], [echo ok])
1279 AS_VAR_SET([foo], ['\a "weird" `value` with; $fun '\''characters
1281 AS_VAR_COPY([bar], [foo])
1283 AS_ECHO(["AS_VAR_GET([foo])-"])
1284 AS_VAR_SET_IF([foo], [echo ok], [echo oops])
1285 AS_VAR_IF([foo], [string], [echo oops]) && echo ok
1286 AS_VAR_PUSHDEF([tmp], [foo])
1287 AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
1288 '], [echo ok], [echo oops]) # 'font-lock
1289 AS_VAR_POPDEF([tmp])
1290 m4_ifdef([tmp], [echo oops])
1292 # Indirects via shell vars.
1295 AS_VAR_SET_IF([foo$num], [echo oops]) && echo ok
1296 AS_VAR_IF([foo$num], [], [echo ok], [echo oops])
1298 AS_VAR_SET_IF([foo$num], [echo ok])
1299 AS_VAR_SET([foo$num], ['\a "weird" `value` with; $fun '\''characters
1301 AS_VAR_COPY([bar], [foo$num])
1303 AS_VAR_COPY([foo$num], [bar])
1305 AS_ECHO(["AS_VAR_GET([foo$num])-"])
1306 AS_VAR_SET_IF([foo$num], [echo ok], [echo oops])
1307 AS_VAR_IF([foo$num], [string], [echo oops]) && echo ok
1308 AS_VAR_PUSHDEF([tmp], [foo$num])
1309 AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
1310 '], [echo ok], [echo oops]) # 'font-lock
1311 AS_VAR_POPDEF([tmp])
1312 m4_ifdef([tmp], [echo oops])
1314 # Indirects via command substitution.
1316 AS_VAR_SET_IF([`echo foo3`], [echo oops]) && echo ok
1317 AS_VAR_IF([`echo foo3`], [], [echo ok], [echo oops])
1319 AS_VAR_SET_IF([`echo foo3`], [echo ok])
1320 AS_VAR_SET([`echo foo3`], ['\a "weird" `value` with; $fun '\''characters
1322 AS_VAR_COPY([bar], [`echo foo3`])
1324 AS_VAR_COPY([`echo foo4`], [bar])
1326 AS_ECHO(["AS_VAR_GET([`echo foo4`])-"])
1327 AS_VAR_SET_IF([`echo foo4`], [echo ok], [echo oops])
1328 AS_VAR_IF([`echo foo4`], [string], [echo oops]) && echo ok
1329 AS_VAR_PUSHDEF([tmp], [`echo foo4`])
1330 AS_VAR_IF([tmp], ['\a "weird" `value` with; $fun '\''characters
1331 '], [echo ok], [echo oops]) # 'font-lock
1332 AS_VAR_POPDEF([tmp])
1333 m4_ifdef([tmp], [echo oops])
1338 AT_CHECK([$CONFIG_SHELL ./script], [], [[ok
1341 \a "weird" `value` WITH; $fun 'characters
1343 \a "weird" `value` WITH; $fun 'characters
1352 \a "weird" `value` WITH; $fun 'characters
1354 \a "weird" `value` WITH; $fun 'characters-
1362 \a "weird" `value` WITH; $fun 'characters
1364 \a "weird" `value` WITH; $fun 'characters-
1373 ## --------------- ##
1374 ## AS_VAR_APPEND. ##
1375 ## --------------- ##
1377 AT_SETUP([AS@&t@_VAR_APPEND])
1378 AT_KEYWORDS([m4sh AS@&t@_VAR])
1380 AT_DATA_M4SH([script.as], [[dnl
1383 AS_VAR_APPEND([foo], ["hello, "])
1384 AS_VAR_APPEND([foo], [world])
1386 # Indirects via shell vars.
1388 AS_VAR_APPEND([foo$num], ['hello, '])
1389 AS_VAR_APPEND([foo$num], [`echo "world"`])
1391 # Indirects via command substitution.
1393 AS_VAR_APPEND([`echo foo2`], [${h}])
1394 AS_VAR_APPEND([`echo foo2`], ["$w"])
1399 AT_CHECK([$CONFIG_SHELL ./script], [],
1408 ## -------------- ##
1410 ## -------------- ##
1412 AT_SETUP([AS@&t@_VAR_ARITH])
1413 AT_KEYWORDS([m4sh AS@&t@_VAR])
1415 AT_DATA_M4SH([script.as], [[dnl
1418 AS_VAR_ARITH([foo], [1 + 1])
1420 # Indirects via shell vars.
1422 AS_VAR_ARITH([foo$num], [\( 2 + 3 \) \* 4])
1424 # Indirects via command substitution.
1425 AS_VAR_ARITH([`echo foo2`], [0 + -2 + $foo1 / 2])
1430 AT_CHECK([$CONFIG_SHELL ./script], [],
1439 ## ----------------- ##
1440 ## AS_INIT cleanup. ##
1441 ## ----------------- ##
1443 AT_SETUP([AS@&t@_INIT cleanup])
1444 AT_KEYWORDS([m4sh m4@&t@_wrap m4@&t@_wrap_lifo])
1446 AT_DATA_M4SH([script.as], [[dnl
1447 dnl Registered before AS_INIT's cleanups
1448 m4_wrap([echo cleanup 1
1450 m4_pushdef([_AS_SHELL_FN_SPY])dnl neutralize the spy, we don't care about it
1452 dnl Registered after AS_INIT's cleanups, thus goes to KILL diversion
1453 m4_wrap([echo cleanup 2
1454 dnl However, nested wraps and diversions can still be used
1455 dnl Also, test wrapping text that looks like parameter reference
1456 m4_wrap([echo cleanup 3
1457 m4_divert_text([M4SH-INIT], [m4_define([foo], [$1])dnl
1460 dnl Registered before AS_INIT's cleanups
1461 m4_wrap_lifo([echo cleanup 5
1467 AT_CHECK([$CONFIG_SHELL ./script], [], [[prep 4
1476 ## ------------------- ##
1477 ## AS_INIT_GENERATED. ##
1478 ## ------------------- ##
1480 AT_SETUP([AS@&t@_INIT_GENERATED])
1481 AT_KEYWORDS([AS@&t@_MESSAGE AS@&t@_MESSAGE_LOG_FD])
1483 dnl First run, no logging, tests shell selection
1484 AT_DATA_M4SH([script.as], [[dnl
1486 AS_INIT_GENERATED([child], [echo hello from child])
1488 AS_ECHO(["SHELL=$SHELL"])
1490 echo hello from parent
1491 AS_ECHO(["SHELL=$SHELL"])
1495 AT_CHECK([$CONFIG_SHELL ./script], [0], [stdout])
1496 AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore])
1497 sed s/parent/child/ <stdout >expout
1498 AT_CHECK([./child], [0], [expout])
1503 AT_CHECK([$CONFIG_SHELL ./script], [0], [expout])
1504 AT_CHECK([cmp child child.bak])
1505 AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore])
1506 sed s/parent/child/ <stdout >expout
1507 AT_CHECK([./child], [0], [expout])
1510 dnl Second run, with logging from parent and child, tests fd handling
1511 AT_DATA_M4SH([script.as], [[dnl
1514 m4_define([AS_MESSAGE_LOG_FD], [5])
1515 exec AS_MESSAGE_LOG_FD>log
1516 AS_INIT_GENERATED([$child], [echo hello1 from $child]) || AS_EXIT([1])
1518 m4_pushdef([AS_MESSAGE_LOG_FD])
1519 AS_MESSAGE([hello2 from ${child}child])
1520 m4_popdef([AS_MESSAGE_LOG_FD])
1521 exec AS_MESSAGE_LOG_FD>>log
1522 AS_MESSAGE([hello3 from child])
1524 AS_MESSAGE([hello from parent])
1525 dnl close log in parent before spawning child, for mingw
1526 exec AS_MESSAGE_LOG_FD>&-
1532 AT_CHECK([$CONFIG_SHELL ./script], [0], [[script: hello from parent
1534 child: hello2 from child
1535 child: hello3 from child
1537 AT_CHECK([[sed 's,:[0-9][0-9]*:,:0:,' log]], [0],
1538 [[script:0: hello from parent
1539 child:0: hello3 from child
1542 # Force write error creating a file on stdout
1543 if test -w /dev/full && test -c /dev/full; then
1544 AT_CHECK([$CONFIG_SHELL ./script /dev/full], [1], [ignore], [ignore])
1550 ## --------------- ##
1551 ## AS_MESSAGE_FD. ##
1552 ## --------------- ##
1554 AT_SETUP([AS@&t@_MESSAGE_FD])
1555 AT_KEYWORDS([AS@&t@_MESSAGE AS@&t@_MESSAGE_LOG_FD AS@&t_ORIGINAL_STDIN_FD])
1556 AT_KEYWORDS([AS@&t@_LINENO_PUSH])
1558 AT_DATA_M4SH([script.as], [[dnl
1560 m4_define([AS_ORIGINAL_STDIN_FD], [5])
1561 m4_define([AS_MESSAGE_LOG_FD], [6])
1562 m4_define([AS_MESSAGE_FD], [7])
1563 exec AS_ORIGINAL_STDIN_FD<&0 </dev/null AS_MESSAGE_LOG_FD>log
1564 if test $[#] -gt 0; then
1565 exec AS_MESSAGE_FD>/dev/null
1567 exec AS_MESSAGE_FD>&1
1569 AS_LINENO_PUSH([100])
1570 cat # tests that stdin is neutralized
1571 AS_MESSAGE([hello world])
1572 cat <&AS_ORIGINAL_STDIN_FD
1576 AT_CHECK([echo goodbye | $CONFIG_SHELL ./script], [0],
1577 [[script: hello world
1580 AT_CHECK([cat log], [0],
1581 [[script:100: hello world
1584 AT_CHECK([echo goodbye | $CONFIG_SHELL ./script silent], [0],
1587 AT_CHECK([cat log], [0],
1588 [[script:100: hello world
1594 ## --------------- ##
1595 ## _AS_CLEAN_DIR. ##
1596 ## --------------- ##
1598 AT_SETUP([_AS@&t@_CLEAN_DIR])
1600 dnl ensure that we can erase all files in a directory. Note that
1601 dnl _AS_CLEAN_DIR needs three globs to catch all these files.
1602 AT_DATA_M4SH([script.as], [[dnl
1604 # Unwritable subdirectories are common during 'make distcheck'.
1605 mkdir sub sub/unwritable || AS_ERROR([failed to mkdir])
1606 touch sub/unwritable/file || AS_ERROR([failed to touch])
1607 chmod a-wx sub/unwritable || AS_ERROR([failed to chmod])
1608 # Cygwin 1.5 can't touch 'sub/...', so make that file optional.
1609 touch sub/a sub/aa sub/aaa sub/.a sub/..a sub/.aa \
1610 || AS_ERROR([failed to touch])
1611 touch sub/... 2>/dev/null
1612 _AS_CLEAN_DIR([sub]) || AS_ERROR([failed to clean])
1613 # rmdir instead of 'rm -fr' here proves that we emptied sub.
1614 rmdir sub || AS_ERROR([failed to rmdir])
1618 AT_CHECK([$CONFIG_SHELL ./script])
1629 AT_DATA_M4SH([script.as], [[dnl
1637 AT_CHECK([$CONFIG_SHELL ./script], [], [foobar