maint: summarize highlights of 1.4.18 release
[m4/ericb.git] / tests / testsuite.at
blob19fc9ee7522001af1a80ca637cc7b95543fb2004
1 # Process with autom4te to create an -*- Autotest -*- test suite.
3 # Test suite for GNU M4.
4 # Copyright (C) 2001, 2006-2010, 2013-2014, 2017 Free Software
5 # Foundation, Inc.
7 # This file is part of GNU M4.
9 # GNU M4 is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # GNU M4 is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 # We need a recent Autotest.
23 m4_version_prereq([2.63b-41])
25 # Default to testing "m4 -b", but allow overrides.
26 dnl This uses knowledge of undocumented autotest internals; hopefully
27 dnl it isn't too much of a problem.  FIXME: Help autoconf document
28 dnl proper usage of HELP_OTHER, at_write_fail, and at_tested (or better
29 dnl yet, add AT_FOO macros that wrap these internal details).
30 m4_divert_text([HELP_OTHER],
31 [cat <<\_ATEOF || at_write_fail=1
33 The environment variable `M4' controls which binary is tested, default `m4 -b'.
34 _ATEOF])
35 m4_divert_text([PREPARE_TESTS],
36 [[if test "${M4+set}" = set; then
37   case $M4 in
38     *[\\/]* ) at_tested= ;;
39     * ) at_tested=`set x $M4; echo $2` ;;
40   esac
41 else
42   M4='m4 -b'
43 fi]])
45 # AT_CHECK_M4(ARGS, [EXIT-STATUS = 0], [STDOUT = `'], [STDERR = `'],
46 #             [STDIN = `/dev/null'], [INHIBIT-D])
47 # ------------------------------------------------------------------
48 # Run m4 with ARGS, and stdin redirected from STDIN, or with stdin closed
49 # if STDIN is `-'.  ARGS may redirect stdout and/or stderr, but should
50 # not redirect stdin.  Expect EXIT-STATUS, with output matching STDOUT and
51 # STDERR as in AT_CHECK.  If STDERR is specified, normalize the observed
52 # error output.  Unless INHIBIT-D is specified, add -d prior to ARGS.
54 # When testing an uninstalled wrapper, tests/m4 is on the path, but invokes
55 # src/m4, which may itself be a libtool wrapper.  Also, some platforms
56 # choose to display argv[0] differently:
57 #    path/to/lt-m4:file:line: message
58 # or m4.exe:file:line: message
59 # to m4:file:line
61 # When testing closed file descriptors, the message is platform-dependent:
62 #    m4: error closing file: Bad file number
63 # to m4: error closing file: Bad file descriptor
65 # When tracing modules, the module name is platform-dependent:
66 #    m4debug: module gnu: opening file `gnu.so'
67 # or m4debug: module gnu: opening file `gnu.a'
68 # to m4debug: module gnu: opening file
70 # When testing modules, a failed module name is platform-dependent:
71 #    m4:input.m4:7: cannot open module `no_such': no_such.so: cannot open shared object file: No such file or directory
72 # or m4:input.m4:7: cannot open module `no_such': can't open the module
73 # to m4:input.m4:7: cannot open module `no_such'
75 # When encountering command line option errors, the error message is
76 # platform-dependent, but contains " option ":
77 #    m4: unrecognized option `--diversions=1' # glibc 2.6
78 # or m4: unrecognized option '--diversions=1' # glibc 2.11
79 # or m4: unknown option -- --diversions       # BSD
80 # or m4: option '--debu' is ambiguous         # glibc 2.11
81 # or m4: ambiguous option -- --debu           # BSD
82 # to m4: bad option
83 m4_define([AT_CHECK_M4],
84 [AT_CHECK([$M4 m4_ifval([$6], [], [-d ])$1 ]m4_if([$5], [-], [<&-],
85                                             [< m4_default([$5], [/dev/null])]),
86           [$2], [$3], m4_case([$4], [], [], [ignore], [ignore], [stderr]))
87 m4_case([$4], [], [], [ignore], [],
88 [AT_CHECK([[$SED 's/^[^:]*[lt-]*m4[.ex]*:/m4:/
89         /^m4debug: module/s/opening file.*/opening file/
90         s/\(cannot open module [^:]*\):.*/\1/
91         s/Bad file number/Bad file descriptor/
92         s/^m4:.* option .*/m4: bad option/
93     ' stderr >&2]], [0], [], [$4])])
96 # M4_ONE_MEG_DEFN
97 # ---------------
98 # emit a code snippet for use in AT_DATA that will define a macro `f' to
99 # consist of 1M bytes of newlines.  With that in place, it is then easy
100 # to use divert and invoke `f' in the test file to force diversions to
101 # spill into a temporary file.
102 m4_define([M4_ONE_MEG_DEFN],
103 [pushdef(`diversion', divnum)divert(-1)
104 define(`f', `
106 define(`f', defn(`f')defn(`f'))
107 define(`f', defn(`f')defn(`f'))
108 define(`f', defn(`f')defn(`f'))
109 define(`f', defn(`f')defn(`f'))
110 define(`f', defn(`f')defn(`f'))
111 define(`f', defn(`f')defn(`f'))
112 define(`f', defn(`f')defn(`f'))
113 define(`f', defn(`f')defn(`f'))
114 define(`f', defn(`f')defn(`f'))
115 define(`f', defn(`f')defn(`f'))
116 define(`f', defn(`f')defn(`f'))
117 define(`f', defn(`f')defn(`f'))
118 define(`f', defn(`f')defn(`f'))
119 define(`f', defn(`f')defn(`f'))
120 define(`f', defn(`f')defn(`f'))
121 define(`f', defn(`f')defn(`f'))
122 define(`f', defn(`f')defn(`f'))
123 define(`f', defn(`f')defn(`f'))
124 define(`f', defn(`f')defn(`f'))
125 define(`f', defn(`f')defn(`f'))
126 divert(diversion)popdef(`diversion')])
128 # AT_TEST_M4(TITLE, INPUT, [STDOUT = `'], [STDERR = `'])
129 # ------------------------------------------------------
130 # Run m4 on INPUT, expecting a success.
131 m4_define([AT_TEST_M4],
132 [AT_SETUP([$1])
133 AT_DATA([[input.m4]], [$2])
134 AT_CHECK_M4([[input.m4]], 0, [$3], [$4])
135 AT_CLEANUP
138 # We use `dnl' in zillions of places...
139 m4_pattern_allow([^dnl$])
141 # We exercise m4.
142 AT_TESTED([m4])
144 # AT_CHECK_GMP
145 # -----------------------
146 # Add keyword `gmp' to the test, and skip the test if the use of GMP
147 # was disabled at configure time.
148 m4_define([AT_CHECK_GMP],
149 [AT_KEYWORDS([gmp])
150 AT_CHECK([if test "x$USE_GMP" = xno ; then
151   echo libgmp support not detected, skipping this test.
152   exit 77
153 fi])])
155 ## ----------- ##
156 ## The suite.  ##
157 ## ----------- ##
159 AT_INIT
161 # Macro definitions, uses, tracing etc.
162 m4_include([macros.at])
164 # Torturing builtins.
165 m4_include([builtins.at])
167 # Options.
168 m4_include([options.at])
170 # Frozen files.
171 m4_include([freeze.at])
173 # Hand crafted tests.
174 m4_include([others.at])
176 # Torturing the modules support.
177 m4_include([modules.at])
179 # From the documention.
180 m4_include([generated.at])