maint: bump copyright year
[m4.git] / tests / options.at
blob29f41c07744013311e16468fb23d24911013ae54
1 # Hand crafted tests for GNU M4.                               -*- Autotest -*-
2 # Copyright (C) 2001, 2006-2010, 2013-2014, 2017 Free Software
3 # Foundation, Inc.
5 # This file is part of GNU M4.
7 # GNU M4 is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # GNU M4 is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 AT_BANNER([Options.])
23 ## ------------------ ##
24 ## deprecated options ##
25 ## ------------------ ##
27 AT_SETUP([deprecated options])
29 dnl -N/--diversions was removed after 1.4.x
30 AT_CHECK_M4([--diversions=1], [1], [], [stderr])
31 AT_CHECK([$SED 's/Try.*help/Try `m4 --help/' stderr], [0],
32 [[m4: bad option
33 Try `m4 --help' for more information.
34 ]])
36 dnl -H/--hashsize are no-ops since 2.0
37 AT_CHECK_M4([-H1 --hashsize=1], [0], [],
38 [[m4: warning: `-H' is deprecated
39 m4: warning: `--hashsize' is deprecated
40 ]])
42 dnl -S/-T are no-ops for compatibility
43 AT_CHECK_M4([-S1 -T1], [0], [],
44 [[m4: warning: `-S' is deprecated
45 m4: warning: `-T' is deprecated
46 ]])
48 dnl -Bint can be confused with its no-op meaning in 1.4.x, but all other
49 dnl uses of -B or its long option are okay
50 AT_CHECK_M4([-B1], [0], [],
51 [[m4: warning: recommend using `-B ./1' instead
52 ]])
53 AT_CHECK_M4([-B./1 --prepend-include=1], [0], [],
54 [[]])
56 dnl --error-output is a misleading name
57 AT_CHECK_M4([--error-output=trace], [0], [],
58 [[m4: warning: `--error-output' is deprecated, use `--debugfile' instead
59 ]])
60 AT_CHECK([rm trace])
62 dnl -o will change meaning in the future
63 AT_CHECK_M4([-otrace], [0], [],
64 [[m4: warning: `-o' is deprecated, use `--debugfile' instead
65 ]])
66 AT_CHECK([rm trace])
68 dnl -e is an odd spelling for --interactive
69 AT_CHECK_M4([-e], [0], [],
70 [[m4: warning: `-e' is deprecated, use `-i' instead
71 ]])
73 dnl --arglength is an older spelling for --debuglen
74 AT_CHECK_M4([--arglength=10], [0], [],
75 [[m4: warning: `--arglength' is deprecated, use `--debuglen' instead
76 ]])
78 AT_CHECK_M4([--arglength=x], [1], [],
79 [[m4: warning: `--arglength' is deprecated, use `--debuglen' instead
80 m4: invalid --arglength argument 'x'
81 ]])
83 dnl --word-regexp from 1.4.x is no longer supported.  Can't test for its
84 dnl alternate spelling -W, as that now means --warnings.
85 AT_CHECK_M4([[--word-regexp='[a-zA-Z0-9_]+']], [0], [],
86 [[m4: warning: `--word-regexp' is deprecated
87 ]])
89 AT_CLEANUP
92 ## ---------- ##
93 ## file names ##
94 ## ---------- ##
96 AT_SETUP([file names])
98 dnl Check that all files are processed even after missing file
99 AT_DATA([in], [[hello world
101 AT_CHECK_M4([oops in], [1], [[hello world
102 ]], [[m4: cannot open file 'oops': No such file or directory
105 dnl Check that '-' means stdin, even if ./- exists.
106 AT_DATA([-], [[hi
108 AT_CHECK_M4([-], [0])
109 AT_CHECK_M4([- --], [0])
110 AT_CHECK_M4([-- -], [0])
111 AT_CHECK_M4([./-], [0], [[hi
113 AT_CHECK_M4([./- --], [0], [[hi
115 AT_CHECK_M4([-- ./-], [0], [[hi
118 AT_CLEANUP
121 ## --------------- ##
122 ## option grouping ##
123 ## --------------- ##
125 AT_SETUP([option grouping])
127 dnl this test group depends on correct settings of POSIXLY_CORRECT
128 if test -n "${POSIXLY_CORRECT+set}" ; then
129   (unset POSIXLY_CORRECT) >/dev/null 2>&1 || {
130     echo "Problem unsetting POSIXLY_CORRECT"
131     AT_CHECK([exit 77])
132   }
133   unset POSIXLY_CORRECT
136 dnl This comes from the "Invoking m4" node; it was easier to write the
137 dnl test separately than to let generate.awk fiddle with it.
138 AT_DATA([a], [[foo 1
139 m@&t@4_dnl()
142 AT_DATA([-d+f], [[hi
145 dnl First, run with GNU semantics
146 AT_CHECK_M4([-QPDfoo -d a -d+f], [0], [[ 1
149 AT_CHECK_M4([-Q -P -D foo -d -d+f -- a], [0], [[ 1
152 AT_CHECK_M4([-QPDfoo -d -- a -d+f], [0], [[ 1
156 AT_CHECK_M4([-Q -P -D foo -d ./a ./-d+f], [0], [[ 1
160 AT_CHECK_M4([--def foo --debug a], [0], [[ 1
161 m@&t@4_dnl()
164 AT_CHECK_M4([--define=foo --debug= -- a], [0], [[ 1
165 m@&t@4_dnl()
168 dnl Next, run with POSIX semantics
169 POSIXLY_CORRECT=1
170 export POSIXLY_CORRECT
172 AT_CHECK_M4([-QPDfoo -d a -d+f], [0], [[ 1
175 AT_CHECK_M4([-Q -P -D foo -d -d+f -- ./a], [0], [[ 1
178 AT_CHECK_M4([-QPDfoo -d -- a -d+f], [0], [[ 1
182 AT_CHECK_M4([-Q -P -D foo -d ./a ./-d+f], [0], [[ 1
186 AT_CHECK_M4([--def foo --debug a], [0], [[ 1
187 m@&t@4_dnl()
190 AT_CHECK_M4([--define=foo --debug= -- a], [0], [[ 1
191 m@&t@4_dnl()
194 AT_CLEANUP
197 ## --------------- ##
198 ## POSIXLY_CORRECT ##
199 ## --------------- ##
201 AT_SETUP([POSIXLY_CORRECT])
203 dnl this test group depends on correct settings of POSIXLY_CORRECT
204 if test -n "${POSIXLY_CORRECT+set}" ; then
205   (unset POSIXLY_CORRECT) >/dev/null 2>&1 || {
206     echo "Problem unsetting POSIXLY_CORRECT"
207     AT_CHECK([exit 77])
208   }
209   unset POSIXLY_CORRECT
212 dnl By default, GNU extensions and warnings are enabled
213 AT_DATA([in], [[__line__
214 dnl()
216 AT_CHECK_M4([in], [0], [[1
217 ]], [[m4:in:2: warning: dnl: extra arguments ignored: 1 > 0
219 AT_CHECK_M4([in -g], [0], [[1
220 ]], [[m4:in:2: warning: dnl: extra arguments ignored: 1 > 0
222 AT_CHECK_M4([in -G], [0], [[__line__
223 ]], [[m4:in:2: warning: dnl: extra arguments ignored: 1 > 0
225 AT_CHECK_M4([in -W], [0], [[1
226 ]], [[m4:in:2: warning: dnl: extra arguments ignored: 1 > 0
228 AT_CHECK_M4([in -Q], [0], [[1
231 dnl Next, run with POSIX semantics
232 POSIXLY_CORRECT=1
233 export POSIXLY_CORRECT
235 dnl POSIXLY_CORRECT implies -G -Q
236 AT_DATA([in], [[__line__
237 dnl()
239 AT_CHECK_M4([in], [0], [[__line__
241 AT_CHECK_M4([in -g], [0], [[1
243 AT_CHECK_M4([in -G], [0], [[__line__
245 AT_CHECK_M4([in -W], [0], [[__line__
246 ]], [[m4:in:2: warning: dnl: extra arguments ignored: 1 > 0
248 AT_CHECK_M4([in -Q], [0], [[__line__
251 AT_CLEANUP
253 ## -------------- ##
254 ## unknown option ##
255 ## -------------- ##
257 AT_SETUP([unknown option])
259 AT_CHECK_M4([--unknown], [1], [], [stderr])
260 AT_CHECK([$SED 's/Try.*help/Try `m4 --help/' stderr], [0],
261 [[m4: bad option
262 Try `m4 --help' for more information.
265 AT_CLEANUP
268 ## --------- ##
269 ## debugfile ##
270 ## --------- ##
272 AT_SETUP([--debugfile])
274 dnl For a while, CVS m4 mistakenly sent debug output to stdout
275 dnl when stdout and stderr were the same file.
277 AT_DATA([[in]], [[foo
280 AT_CHECK_M4([--debugfile=trace1 -tfoo -Dfoo=bar in 2>&1], [0], [[bar
283 AT_CHECK_M4([--debugfile=trace2 -tfoo -Dfoo=bar in], [0], [[bar
286 AT_CHECK([cmp trace1 trace2])
288 dnl m4 1.4.x mistakenly created the trace file.  --help and --version
289 dnl should always override, even if they come later in the command line
290 AT_CHECK_M4([--debugfile=trace3 --help], [0], [ignore])
291 AT_CHECK_M4([--debugfile=trace3 --version], [0], [ignore])
292 AT_CHECK([test -f trace3], [1])
294 dnl check that trace file failure causes an error, but allows processing
295 AT_CHECK_M4([--debugfile=no_such_dir/trace -tfoo -Dfoo=bar in], [1],
296 [[bar
297 ]], [[m4: cannot set debug file 'no_such_dir/trace': No such file or directory
298 m4trace: -1- foo -> `bar'
301 dnl check that empty trace file discards trace data
302 AT_CHECK_M4([--debugfile= -tfoo -Dfoo=bar in], [0],
303 [[bar
306 dnl check that all tracing gets diverted to the trace file.  Don't use
307 dnl AT_CHECK_M4 on the first run, because sanitizing stderr breaks the
308 dnl comparison with the raw data in the trace file of the second run.
309 AT_CHECK([$M4 -dV in], [0], [[foo
310 ]], [stderr])
311 mv stderr expout
312 AT_CHECK_M4([--debugfile=trace4 -dV in], [0], [[foo
314 AT_CHECK([cat trace4], [0], [expout])
316 dnl check that order matters
317 AT_DATA([in1], [[bar
319 AT_DATA([in2], [[errprint(`hi
320 ')dnl
323 AT_CHECK_M4([-Dbar=hello -tbar --debugfile= in1 --debugfile in2], [0],
324 [[hello
325 hello
326 ]], [[hi
327 m4trace: -1- bar -> `hello'
330 AT_CLEANUP
333 ## -------- ##
334 ## debuglen ##
335 ## -------- ##
337 AT_SETUP([--debuglen])
339 dnl Check for argument validation.
341 AT_DATA([in],
342 [[define(`echo', `$@')dnl
343 traceon(`echo')dnl
344 echo(`long string')
347 AT_CHECK_M4([--debuglen=-1 in], [1], [],
348 [[m4: invalid --debuglen argument '-1'
351 AT_CHECK_M4([--debuglen oops in], [1], [],
352 [[m4: invalid --debuglen argument 'oops'
355 AT_CHECK_M4([-l 10oops in], [1], [],
356 [[m4: invalid suffix in -l argument '10oops'
359 dnl MiB is the suffix to implict 1, resulting in 1048576
360 AT_CHECK_M4([-lMiB in], [0], [[long string
361 ]], [[m4trace: -1- echo(`long string') -> ``long string''
364 dnl this assumes size_t is no bigger than 64 bits
365 AT_CHECK_M4([-l 123456789012345678901234567890 in], [1], [],
366 [[m4: -l argument '123456789012345678901234567890' too large
368 AT_CHECK_M4([--debugl 123456789012345678901234567890 in], [1], [],
369 [[m4: --debuglen argument '123456789012345678901234567890' too large
372 dnl per POSIX guidelines, this is a decimal number 10, not octal 8
373 AT_CHECK_M4([-l 010 in], [0], [[long string
374 ]], [[m4trace: -1- echo(`long strin...') -> ``long stri...'
377 AT_CHECK_M4([-l 3 in], [0], [[long string
378 ]], [[m4trace: -1- echo(`lon...') -> ``lo...'
381 AT_CHECK_M4([--debuglen=3 -l0 in], [0], [[long string
382 ]], [[m4trace: -1- echo(`long string') -> ``long string''
385 AT_CLEANUP
388 ## --------- ##
389 ## debugmode ##
390 ## --------- ##
392 AT_SETUP([--debugmode])
394 AT_DATA([[in]],
395 [[include(`nested')dnl
396 len(`abc')
399 AT_DATA([[nested]],
400 [[m4wrap(`divnum
401 ')dnl
404 dnl AT_CHECK_M4 starts life with -d.  Make sure it looks like -d+adeq.
405 AT_CHECK_M4([-tlen in], [0], [[3
407 ]], [[m4trace: -1- len(`abc') -> `3'
410 AT_CHECK_M4([-tlen -dfl -d in], [0], [[3
412 ]], [[m4trace:in:2: -1- len(`abc') -> `3'
415 dnl -d after file is deferred (but this is still useful for some flags).
416 AT_CHECK_M4([-tlen in -dfli], [0], [[3
418 ]], [[m4trace: -1- len(`abc') -> `3'
419 m4debug: input from m4wrap recursion level 1
420 m4debug: input from m4wrap exhausted
423 dnl Test all flags.
424 AT_CHECK_M4([-dV in], [0], [[3
426 ]], [[m4debug: module m4: opening file
427 m4debug: module m4: init hook called
428 m4debug: module m4: opened
429 m4debug: module m4: builtins loaded
430 m4debug: module gnu: opening file
431 m4debug: module gnu: init hook called
432 m4debug: module gnu: opened
433 m4debug: module gnu: builtins loaded
434 m4debug: module gnu: macros loaded
435 m4debug: path search for 'in' found 'in'
436 m4debug: input read from 'in'
437 m4trace:in:1: -1- id 1: include ... = <include>{m4}
438 m4debug:in:1: path search for 'nested' found 'nested'
439 m4debug:in:1: input read from 'nested'
440 m4trace:in:1: -1- id 1: include(`nested') -> <file: nested>
441 m4trace:nested:1: -1- id 2: m4wrap ... = <m4wrap>{m4}
442 m4trace:nested:1: -1- id 2: m4wrap(`divnum
443 ') -> `'
444 m4trace:nested:2: -1- id 3: dnl ... = <dnl>{m4}
445 m4trace:nested:2: -1- id 3: dnl -> `'
446 m4debug:nested:3: input reverted to in, line 1
447 m4trace:in:1: -1- id 4: dnl ... = <dnl>{m4}
448 m4trace:in:1: -1- id 4: dnl -> `'
449 m4trace:in:2: -1- id 5: len ... = <len>{m4}
450 m4trace:in:2: -1- id 5: len(`abc') -> `3'
451 m4debug:in:3: input exhausted
452 m4debug: input from m4wrap recursion level 1
453 m4trace:nested:1: -1- id 6: divnum ... = <divnum>{m4}
454 m4trace:nested:1: -1- id 6: divnum -> `0'
455 m4debug: input from m4wrap exhausted
458 dnl Test addition and subtraction of flags.
459 AT_CHECK_M4([--debug=-e --debugmode=+xt in], [0], [[3
461 ]], [[m4trace: -1- id 1: include(`nested')
462 m4trace: -1- id 2: m4wrap(`divnum
464 m4trace: -1- id 3: dnl
465 m4trace: -1- id 4: dnl
466 m4trace: -1- id 5: len(`abc')
467 m4trace: -1- id 6: divnum
470 dnl Test that shorter prefix is ambiguous.
471 AT_CHECK_M4([--debu], [1], [], [stderr])
472 AT_CHECK([$SED -e 's/Try.*--help/Try `m4 --help/' stderr], [0],
473 [[m4: bad option
474 Try `m4 --help' for more information.
477 AT_CLEANUP
480 ## ---------------- ##
481 ## discard comments ##
482 ## ---------------- ##
484 AT_SETUP([--discard-comments])
486 AT_DATA([[in]],
487 [[This is not a comment # but this is.
488 # This line should disappear completely.
489 This should not disappear.
490 changecom(`<!--', `-->')
491 html <!--
492 comment
493  --> ends.
496 AT_CHECK_M4([-c in], [0],
497 [[This is not a comment This should not disappear.
499 html  ends.
502 dnl check that even when discarding, a comment must be terminated by EOF
503 AT_DATA([in], [[changecom(`/*', `*/')dnl
504 /* unterminated comment
506 AT_CHECK_M4([--discard-comments in], [1], [],
507 [[m4:in:2: end of file in comment
510 AT_CLEANUP
513 ## -------------- ##
514 ## fatal warnings ##
515 ## -------------- ##
517 AT_SETUP([--fatal-warnings])
519 AT_DATA([[in]],
520 [[dnl()
521 dnl()
522 dnl()
525 dnl By default, warnings don't affect exit status
526 AT_CHECK_M4([in], [0], [],
527 [[m4:in:1: warning: dnl: extra arguments ignored: 1 > 0
528 m4:in:2: warning: dnl: extra arguments ignored: 1 > 0
529 m4:in:3: warning: dnl: extra arguments ignored: 1 > 0
532 dnl With one -E, exit status changes, but execution continues
533 AT_CHECK_M4([-E in], [1], [],
534 [[m4:in:1: warning: dnl: extra arguments ignored: 1 > 0
535 m4:in:2: warning: dnl: extra arguments ignored: 1 > 0
536 m4:in:3: warning: dnl: extra arguments ignored: 1 > 0
539 dnl With two -E, execution halts immediately
540 AT_CHECK_M4([--fatal-warnings --fatal-warnings in], [1], [],
541 [[m4:in:1: warning: dnl: extra arguments ignored: 1 > 0
544 dnl Exit status can't be affected if there were no warnings
545 AT_CHECK_M4([-EEQ in], [0])
547 AT_CLEANUP
550 ## ---------------- ##
551 ## help and version ##
552 ## ---------------- ##
554 AT_SETUP([--help and --version])
556 AT_CHECK_M4([--help], [0], [stdout])
557 AT_CHECK([[$SED -n -e 's|Usage:.*\[OPTION\]... \[FILE\]...|success|p' stdout]],
558 [0], [success
561 AT_CHECK_M4([--version], [0], [stdout])
562 AT_CHECK([[$SED -n -e 's|There is NO WARRANTY.*|success|p' stdout]],
563 [0], [success
566 dnl make sure option specified first takes precedence
567 AT_CHECK_M4([--help --version], [0], [stdout])
568 AT_CHECK([[$SED -n -e 's|Usage:.*\[OPTION\]... \[FILE\]...|success|p' stdout]],
569 [0], [success
572 AT_CHECK_M4([--version --help], [0], [stdout])
573 AT_CHECK([[$SED -n -e 's|There is NO WARRANTY.*|success|p' stdout]],
574 [0], [success
577 AT_CLEANUP
580 ## ------------------ ##
581 ## import-environment ##
582 ## ------------------ ##
584 AT_SETUP([--import-environment])
586 AT_DATA([[in]],
587 [[`TEST'=TEST
588 `ZAPPED'=ZAPPED
589 `OVERRIDE'=OVERRIDE
592 TEST='This is an environment variable'
593 export TEST
595 ZAPPED='This is an environment variable which we will delete'
596 export ZAPPED
598 OVERRIDE='This is an environment variable which we will change'
599 export OVERRIDE
601 AT_CHECK_M4([--import-environment -UZAPPED -DOVERRIDE='It is changed.' in],
602 [0], [[TEST=This is an environment variable
603 ZAPPED=ZAPPED
604 OVERRIDE=It is changed.
607 AT_CLEANUP
610 ## ------------- ##
611 ## nesting-limit ##
612 ## ------------- ##
614 AT_SETUP([--nesting-limit])
616 dnl Check for argument validation.
618 AT_DATA([in],
619 [[define(`echo', `$@')dnl
620 echo(echo(echo(echo(`nested string'))))
621 echo(echo(echo(echo(echo(echo(echo(echo(echo(`nested string')))))))))
624 AT_CHECK_M4([--nesting-limit=-1 in], [1], [],
625 [[m4: invalid --nesting-limit argument '-1'
628 AT_CHECK_M4([--nesting-limit oops in], [1], [],
629 [[m4: invalid --nesting-limit argument 'oops'
632 AT_CHECK_M4([-L 10oops in], [1], [],
633 [[m4: invalid suffix in -L argument '10oops'
636 dnl MiB is the suffix to implict 1, resulting in 1048576
637 AT_CHECK_M4([-LMiB in], [0], [[nested string
638 nested string
641 dnl this assumes size_t is no bigger than 64 bits
642 AT_CHECK_M4([-L 123456789012345678901234567890 in], [1], [],
643 [[m4: -L argument '123456789012345678901234567890' too large
645 AT_CHECK_M4([--nest 123456789012345678901234567890 in], [1], [],
646 [[m4: --nesting-limit argument '123456789012345678901234567890' too large
649 AT_CHECK_M4([-L 5 in], [1], [[nested string
651 [[m4:in:3: recursion limit of 5 exceeded, use -L<N> to change it
654 dnl per POSIX guidelines, this is a decimal number 10, not octal 8
655 AT_CHECK_M4([-L 010 in], [0], [[nested string
656 nested string
659 AT_CHECK_M4([--nesting-limit=3 -L0 in], [0], [[nested string
660 nested string
663 AT_CLEANUP
666 ## --------------- ##
667 ## prepend-include ##
668 ## --------------- ##
670 AT_SETUP([--prepend-include])
672 dnl Lots of data to set up.
673 AT_DATA([[in]],
674 [[include(`foo')dnl
675 include(`bar')dnl
676 include(`bad')dnl
677 include(`blah')dnl
680 AT_CHECK([mkdir pre post])
682 AT_DATA([[pre/foo]], [[in pre/foo
684 AT_DATA([[foo]], [[in ./foo
686 AT_DATA([[bar]], [[in ./bar
688 AT_DATA([[post/bar]], [[in post/bar
690 AT_DATA([[post/blah]], [[in post/blah
693 dnl Make circular links in the subdirectories, to ensure that the error
694 dnl message when bad cannot be opened comes from the search in ., regardless
695 dnl of what else was searched.
696 AT_CHECK([ln -s bad pre/bad])
697 AT_CHECK([ln -s bad post/bad])
699 dnl Finally, see that it all works.
700 AT_CHECK_M4([-I post -B pre in], [1],
701 [[in pre/foo
702 in ./bar
703 in post/blah
704 ]], [[m4:in:3: include: cannot open file 'bad': No such file or directory
707 AT_CLEANUP
710 ## ------------- ##
711 ## regexp-syntax ##
712 ## ------------- ##
714 AT_SETUP([--regexp-syntax])
716 dnl test argument validation
718 AT_DATA([[in]], [[regexp(`(', `(')
721 AT_CHECK_M4([--regexp-syntax=unknown in], [1], [],
722 [[m4: bad syntax-spec: 'unknown'
725 AT_CHECK_M4([--regexp-syntax= in], [0], [[0
728 AT_CHECK_M4([-rEXTENDED in], [0], [[
729 ]], [[m4:in:1: warning: regexp: bad regular expression '(': Unmatched ( or \(
732 AT_CHECK_M4([-rgnu-m4 in], [0], [[0
735 AT_CHECK_M4([-r"gnu M4" in], [0], [[0
738 dnl Test behavior of -r intermixed with files
739 AT_CHECK_M4([-rEXTENDED in --regexp-syntax in], [0], [[
741 ]], [[m4:in:1: warning: regexp: bad regular expression '(': Unmatched ( or \(
744 AT_CLEANUP
747 ## ----- ##
748 ## safer ##
749 ## ----- ##
751 AT_SETUP([--safer])
753 dnl with --safer, the debugfile macro is crippled, but --debugfile is not
754 AT_DATA([[in]],
755 [[define(`foo', `1')foo
756 debugfile(`trace2')
757 define(`foo', `2')foo
760 AT_CHECK_M4([--safer --debugfile=trace1 -t foo in], [1],
764 ]], [[m4:in:2: debugfile: disabled by --safer
767 AT_CHECK([test -f trace2], [1])
768 AT_CHECK([cat trace1], [0],
769 [[m4trace: -1- foo -> `1'
770 m4trace: -1- foo -> `2'
773 dnl make sure builtin cannot bypass --safer, and that mkstemp does not
774 dnl create file
775 AT_DATA([[in]], [[builtin(`mkstemp', `./fooXXXXXX')
778 AT_CHECK([echo foo*], [0], [foo*
781 AT_CHECK_M4([--safer in], [1], [[
782 ]], [[m4:in:1: mkstemp: disabled by --safer
785 AT_CHECK([echo foo*], [0], [foo*
788 AT_CLEANUP
791 ## ---------- ##
792 ## syncoutput ##
793 ## ---------- ##
795 AT_SETUP([--syncoutput])
797 dnl -s/--synclines implies --syncoutput=1
798 AT_DATA([in], [[hi
800 AT_CHECK_M4([-s in], [0],
801 [[#line 1 "in"
804 AT_CHECK_M4([--synclines in], [0],
805 [[#line 1 "in"
809 dnl test intermixing option and files
810 AT_CHECK_M4([in --syncoutput=1 in --syncoutput in], [0],
811 [[hi
812 #line 1 "in"
817 dnl test parse error
818 AT_CHECK_M4([--syncoutput=huh in], [0],
819 [[hi
820 ]], [[m4: warning: --syncoutput: unknown directive 'huh'
823 AT_CLEANUP
825 AT_SETUP([--syncoutput and diversions])
827 dnl synclines should always start at the beginning of a line.
828 dnl this does not (yet) happen reliably when diversions do not
829 dnl always end in newline
830 AT_XFAIL_IF([:])
831 AT_DATA([in.m4], [[divert(2)2divert(1)1
833 undivert
836 AT_CHECK_M4([-s in.m4], [0], [[1
837 #line 1 "stdin"
841 AT_CLEANUP
844 ## -------------------- ##
845 ## traceon and traceoff ##
846 ## -------------------- ##
848 AT_SETUP([--traceon and --traceoff])
850 dnl test intermixing with files
851 AT_DATA([[in]], [[divnum
853 AT_CHECK_M4([-d+x in --traceon=divnum in --traceoff=divnum in], [0],
857 ]], [[m4trace: -1- id 2: divnum -> `0'
860 dnl test that --traceoff does not warn on untraced name
861 AT_CHECK_M4([--traceoff=unknown], [0])
863 AT_CLEANUP