]> git.saurik.com Git - bison.git/blob - tests/output.at
3e815d70abc0571184c980d96aa15bb718c5fa8b
[bison.git] / tests / output.at
1 # Checking the output filenames. -*- Autotest -*-
2 # Copyright (C) 2000, 2001, 2002, 2005, 2006, 2007, 2008 Free Software
3 # Foundation, Inc.
4
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 AT_BANNER([[Output file names.]])
19
20
21 # AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES, [SHELLIO],
22 # [ADDITIONAL-TESTS])
23 # -----------------------------------------------------------------------------
24 m4_define([AT_CHECK_OUTPUT],
25 [AT_SETUP([[Output files: $2 $3 $5]])
26 case "$1" in
27 */*) mkdir `echo "$1" | sed 's,/.*,,'`;;
28 esac
29 AT_DATA([$1],
30 [[$2
31 %%
32 foo: {};
33 ]])
34
35 AT_BISON_CHECK([$3 $1 $5], 0)
36 AT_CHECK([ls $4], [], [ignore])
37 $6
38 AT_CLEANUP
39 ])
40
41 AT_CHECK_OUTPUT([foo.y], [], [-dv],
42 [foo.output foo.tab.c foo.tab.h])
43 AT_CHECK_OUTPUT([foo.y], [], [-dv],
44 [foo.output foo.tab.c foo.tab.h],
45 [>&-])
46 AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
47 [foo.c foo.h foo.output])
48 AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
49 [foo.output foo.tab.c foo.tab.h])
50 AT_CHECK_OUTPUT([foo.y], [], [-dv -y],
51 [y.output y.tab.c y.tab.h])
52 AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar],
53 [bar.output bar.tab.c bar.tab.h])
54 AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],
55 [foo.c foo.dot foo.h foo.output])
56
57
58 AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [],
59 [foo.output foo.tab.c foo.tab.h])
60 AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[],
61 [y.output y.tab.c y.tab.h])
62
63 AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[],
64 [y.output y.tab.c y.tab.h])
65
66 # Exercise %output and %file-prefix including deprecated `='
67 AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [],
68 [bar.output bar.tab.c bar.tab.h])
69 AT_CHECK_OUTPUT([foo.y], [%output="bar.c" %defines %verbose %yacc],[],
70 [bar.output bar.c bar.h])
71 AT_CHECK_OUTPUT([foo.y],
72 [%file-prefix="baz" %output "bar.c" %defines %verbose %yacc],
73 [],
74 [bar.output bar.c bar.h])
75
76
77 # Check priorities of extension control.
78 AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [],
79 [foo.output foo.tab.cc foo.tab.hh])
80
81 AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c],
82 [foo.c foo.h foo.output])
83
84 AT_CHECK_OUTPUT([foo.yy], [],
85 [--defines=foo.hpp -o foo.c++],
86 [foo.c++ foo.hpp])
87
88 AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"],
89 [-o foo.c++],
90 [foo.c++ foo.hpp])
91
92 AT_CHECK_OUTPUT([foo.yy], [],
93 [-o foo.c++ --graph=foo.gph],
94 [foo.c++ foo.gph])
95
96
97 ## ------------ ##
98 ## C++ output. ##
99 ## ------------ ##
100
101 m4_define([AT_CHECK_NO_SUBDIR_PART],
102 [# Also make sure that the includes do not refer to the subdirectory.
103 AT_CHECK([grep 'include .subdir/' $1.cc], 1, [])
104 AT_CHECK([grep 'include .subdir/' $1.hh], 1, [])
105 ])
106
107 AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
108 [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh])
109
110 AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
111 [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh],
112 [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
113
114 AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose],
115 [-o subdir/foo.cc],
116 [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh],
117 [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
118
119
120 # AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR,
121 # [EXIT-STATUS])
122 # ------------------------------------------------------------------
123 m4_define([AT_CHECK_CONFLICTING_OUTPUT],
124 [AT_SETUP([Conflicting output files: $2 $3])
125 case "$1" in
126 */*) mkdir `echo "$1" | sed 's,/.*,,'`;;
127 esac
128 AT_DATA([$1],
129 [[$2
130 %%
131 foo: {};
132 ]])
133
134 AT_BISON_CHECK([$3 $1], $5, [], [$4])
135 AT_CLEANUP
136 ])
137
138 AT_CHECK_CONFLICTING_OUTPUT([foo.y],
139 [], [--graph="foo.tab.c"],
140 [foo.y: warning: conflicting outputs to file `foo.tab.c'
141 ])
142
143 AT_CHECK_CONFLICTING_OUTPUT([foo.y],
144 [%defines "foo.output"], [-v],
145 [foo.y: warning: conflicting outputs to file `foo.output'
146 ])
147
148 AT_CHECK_CONFLICTING_OUTPUT([foo.y],
149 [%skeleton "lalr1.cc" %defines], [--graph="location.hh"],
150 [foo.y: warning: conflicting outputs to file `location.hh'
151 ])
152
153 AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y],
154 [foo.y: fatal error: refusing to overwrite the input file `foo.y'
155 ], 1)
156
157
158 # AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
159 # -----------------------------------------------------------------------------
160 m4_define([AT_CHECK_OUTPUT_FILE_NAME],
161 [AT_SETUP([Output file name: $1])
162
163 AT_DATA_GRAMMAR([glr.y],
164 [[%glr-parser
165 %code {
166 int yylex (void);
167 void yyerror (const char *);
168 }
169 %%
170 start: {};
171 ]])
172 AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" glr.y])
173 AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
174 AT_COMPILE([glr.o], [-c "AS_ESCAPE([$1.c])"])
175 $2
176
177 AT_DATA_GRAMMAR([cxx.y],
178 [[%skeleton "lalr1.cc"
179 %code { int yylex (yy::parser::semantic_type*); }
180 %%
181 start: {};
182 ]])
183 AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" cxx.y])
184 AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
185 AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.c])"])
186 $2
187
188 AT_CLEANUP
189 ])
190
191 # Notice that the header file name here cannot contain
192 # `"' since FILENAME in `#include "FILENAME"' cannot.
193 AT_CHECK_OUTPUT_FILE_NAME([[`~!@#$%^&*()-=_+{}[]|\:;<>, .']])
194 dnl Work around a bug in m4_expand that broke AT_SETUP in autoconf 2.62,
195 dnl by using the definition from 2.63.
196 m4_define([m4_expand], [_$0(-=<{($1)}>=-)])
197 m4_define([_m4_expand],
198 [m4_changequote([-=<{(], [)}>=-])$1m4_changequote([, ])])
199 AT_CHECK_OUTPUT_FILE_NAME([[(]])
200 AT_CHECK_OUTPUT_FILE_NAME([[)]])
201 AT_CHECK_OUTPUT_FILE_NAME([[#]])
202 AT_CHECK_OUTPUT_FILE_NAME([[@@]])
203 AT_CHECK_OUTPUT_FILE_NAME([[@{]])
204 AT_CHECK_OUTPUT_FILE_NAME([[@}]])
205 AT_CHECK_OUTPUT_FILE_NAME([[@<:@]])
206 AT_CHECK_OUTPUT_FILE_NAME([[@:>@]])