]> git.saurik.com Git - bison.git/blame - tests/skeletons.at
quote consistently and make tests pass with new quoting from gnulib
[bison.git] / tests / skeletons.at
CommitLineData
a7867f53 1# Checking skeleton support. -*- Autotest -*-
6e30ede8 2
c932d613 3# Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
a7867f53 4
f16b0819 5# This program is free software: you can redistribute it and/or modify
a7867f53 6# it under the terms of the GNU General Public License as published by
f16b0819
PE
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
a7867f53
JD
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.
f16b0819 14#
a7867f53 15# You should have received a copy of the GNU General Public License
f16b0819 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
a7867f53 17
3eb82471 18AT_BANNER([[Skeleton Support.]])
a7867f53
JD
19
20## ------------------------------ ##
9611cfa2 21## Relative skeleton file names. ##
a7867f53
JD
22## ------------------------------ ##
23
9611cfa2 24AT_SETUP([[Relative skeleton file names]])
a7867f53
JD
25
26AT_CHECK([[mkdir tmp]])
27
28AT_DATA([[tmp/skel.c]],
29[[m4@&t@_divert_push(0)d@&t@nl
30@output(b4_parser_file_name@)d@&t@nl
31b4_percent_define_get([[test]])
32m4@&t@_divert_pop(0)
33]])
34
35AT_DATA([[skel.c]],
36[[m4@&t@_divert_push(0)d@&t@nl
37@output(b4_parser_file_name@)d@&t@nl
38b4_percent_define_get([[test]]) -- Local
39m4@&t@_divert_pop(0)
40]])
41
42AT_DATA([[tmp/input-gram.y]],
43[[%skeleton "./skel.c"
44%define test "Hello World"
45%%
46start: ;
47]])
48
49AT_DATA([[input-gram.y]],
50[[%skeleton "./skel.c"
51%define test "Hello World"
52%%
53start: ;
54]])
55
56AT_DATA([[tmp/input-cmd-line.y]],
57[[%define test "Hello World"
58%%
59start: ;
60]])
61
da730230 62AT_BISON_CHECK([[tmp/input-gram.y]])
a7867f53
JD
63AT_CHECK([[cat input-gram.tab.c]], [[0]],
64[[Hello World
65]])
66
da730230 67AT_BISON_CHECK([[input-gram.y]])
a7867f53
JD
68AT_CHECK([[cat input-gram.tab.c]], [[0]],
69[[Hello World -- Local
70]])
71
da730230 72AT_BISON_CHECK([[--skeleton=tmp/skel.c tmp/input-cmd-line.y]])
a7867f53
JD
73AT_CHECK([[cat input-cmd-line.tab.c]], [[0]],
74[[Hello World
75]])
76
77AT_CLEANUP
78
79
3eb82471 80## ------------------------------- ##
9611cfa2 81## Installed skeleton file names. ##
3eb82471 82## ------------------------------- ##
a7867f53 83
9611cfa2 84AT_SETUP([[Installed skeleton file names]])
a7867f53
JD
85
86m4_pushdef([AT_GRAM],
87[[%{
88 #include <stdio.h>
89 void yyerror (char const *msg);
90 int yylex (void);
91%}
92
93%error-verbose
94%token 'a'
95
96%%
97
98start: ;
99
100%%
101
102void
103yyerror (char const *msg)
104{
105 fprintf (stderr, "%s\n", msg);
106}
107
108int
109yylex (void)
110{
111 return 'a';
112}
113
114int
115main (void)
116{
117 return yyparse ();
118}
119]])
120
121AT_DATA([[input-cmd-line.y]],
122[AT_GRAM])
123
124AT_DATA([[input-gram.y]],
125[[%skeleton "yacc.c"]
126AT_GRAM])
127
da730230 128AT_BISON_CHECK([[--skeleton=yacc.c -o input-cmd-line.c input-cmd-line.y]])
a7867f53
JD
129AT_COMPILE([[input-cmd-line]])
130AT_PARSER_CHECK([[./input-cmd-line]], [[1]], [],
131[[syntax error, unexpected 'a', expecting $end
132]])
133
da730230 134AT_BISON_CHECK([[-o input-gram.c input-gram.y]])
a7867f53
JD
135AT_COMPILE([[input-gram]])
136AT_PARSER_CHECK([[./input-gram]], [[1]], [],
137[[syntax error, unexpected 'a', expecting $end
138]])
139
140m4_popdef([AT_GRAM])
141
142AT_CLEANUP
9611cfa2
JD
143
144
145## ------------------------------------------------------ ##
922bdd7f 146## %define Boolean variables: invalid skeleton defaults. ##
9611cfa2
JD
147## ------------------------------------------------------ ##
148
922bdd7f 149AT_SETUP([[%define Boolean variables: invalid skeleton defaults]])
9611cfa2 150
9611cfa2
JD
151AT_DATA([[skel.c]],
152[[b4_percent_define_default([[foo]], [[bogus value]])
153b4_percent_define_flag_if([[foo]])
154]])
155
156AT_DATA([[input.y]],
157[[%skeleton "./skel.c"
158%%
159start: ;
160]])
161
da730230 162AT_BISON_CHECK([[input.y]], [[1]], [[]],
580c075d 163[[<skeleton default value>: invalid value for %define Boolean variable `foo'
9611cfa2
JD
164]])
165
166AT_CLEANUP
167
168
7dc4a694
JD
169## --------------------------------------------- ##
170## Complaining during macro argument expansion. ##
171## --------------------------------------------- ##
172
173AT_SETUP([[Complaining during macro argument expansion]])
174
175AT_DATA([[skel1.c]],
176[[m4@&t@_define([foow], [b4_warn([[foow fubar]])])
177m4@&t@_define([foowat], [b4_warn_at([[foow.y:2.3]],
178 [[foow.y:5.4]], [[foowat fubar]])])
179m4@&t@_define([fooc], [b4_complain([[fooc fubar]])])
180m4@&t@_define([foocat], [b4_complain_at([[fooc.y:1.1]],
181 [[fooc.y:10.6]], [[foocat fubar]])])
182m4@&t@_define([foof], [b4_fatal([[foof fubar]])])
183m4@&t@_if(foow, [1], [yes])
184m4@&t@_if(foowat, [1], [yes])
185m4@&t@_if(fooc, [1], [yes])
186m4@&t@_if(foocat, [1], [yes])
187m4@&t@_if(foof, [1], [yes])
188]])
189
190AT_DATA([[input1.y]],
191[[%skeleton "./skel1.c"
192%%
193start: ;
194]])
195
da730230 196AT_BISON_CHECK([[input1.y]], [[1]], [[]],
7dc4a694
JD
197[[input1.y: warning: foow fubar
198foow.y:2.3-5.3: warning: foowat fubar
199input1.y: fooc fubar
200fooc.y:1.1-10.5: foocat fubar
201input1.y: fatal error: foof fubar
202]])
203
204AT_DATA([[skel2.c]],
205[[m4@&t@_define([foofat], [b4_fatal_at([[foof.y:12.11]],
206 [[foof.y:100.123]], [[foofat fubar]])])
207m4@&t@_if(foofat, [1], [yes])
208]])
209
210AT_DATA([[input2.y]],
211[[%skeleton "./skel2.c"
212%%
213start: ;
214]])
215
da730230 216AT_BISON_CHECK([[input2.y]], [[1]], [[]],
7dc4a694
JD
217[[foof.y:12.11-100.122: fatal error: foofat fubar
218]])
219
35b8730d
JD
220AT_DATA([[skel3.c]],
221[[b4_complain_at(b4_percent_define_get_loc([[bogus]]), [[bad value]])
222]])
223
224AT_DATA([[input3.y]],
225[[%skeleton "./skel3.c"
226%%
227start: ;
228]])
229
da730230 230AT_BISON_CHECK([[input3.y]], [[1]], [[]],
35b8730d
JD
231[[input3.y: fatal error: undefined %define variable `bogus' passed to b4_percent_define_get_loc
232]])
233
234AT_DATA([[skel4.c]],
235[[b4_warn_at(b4_percent_define_get_syncline([[bogus]]), [[bad value]])
236]])
237
238AT_DATA([[input4.y]],
239[[%skeleton "./skel4.c"
240%%
241start: ;
242]])
243
da730230 244AT_BISON_CHECK([[input4.y]], [[1]], [[]],
35b8730d
JD
245[[input4.y: fatal error: undefined %define variable `bogus' passed to b4_percent_define_get_syncline
246]])
247
7dc4a694
JD
248AT_CLEANUP
249
250
251## --------------------------------------- ##
252## Fatal errors make M4 exit immediately. ##
253## --------------------------------------- ##
254
255AT_SETUP([[Fatal errors make M4 exit immediately]])
256
257AT_DATA([[skel1.c]],
258[[b4_complain([[non-fatal error]])
259b4_fatal([[M4 should exit immediately here]])
260m4@&t@_fatal([this should never be evaluated])
261]])
262
263AT_DATA([[input1.y]],
264[[%skeleton "./skel1.c"
265%%
266start: ;
267]])
268
da730230 269AT_BISON_CHECK([[input1.y]], [[1]], [[]],
7dc4a694
JD
270[[input1.y: non-fatal error
271input1.y: fatal error: M4 should exit immediately here
272]])
273
274AT_DATA([[skel2.c]],
275[[b4_warn([[morning]])
276b4_fatal_at([[foo.y:1.5]], [[foo.y:1.7]], [[M4 should exit immediately here]])
277m4@&t@_fatal([this should never be evaluated])
278]])
279
280AT_DATA([[input2.y]],
281[[%skeleton "./skel2.c"
282%%
283start: ;
284]])
285
da730230 286AT_BISON_CHECK([[input2.y]], [[1]], [[]],
7dc4a694
JD
287[[input2.y: warning: morning
288foo.y:1.5-6: fatal error: M4 should exit immediately here
289]])
290
291AT_CLEANUP
47fa5747
JD
292
293
294## ------------------------------------------------ ##
295## Fatal errors but M4 continues producing output. ##
296## ------------------------------------------------ ##
297
298# At one time, if Bison encountered a fatal error during M4 processing,
299# Bison failed to drain M4's output pipe. The result was a SIGPIPE.
300# On some platforms, the default disposition for SIGPIPE is terminate,
301# which was fine. On others, it's ignore, which caused M4 to report
302# the broken pipe to the user, but we don't want to bother the user with
303# that.
304
305# There is a race condition somewhere. That is, before the associated
306# fix, running this test group many times in a row would occasionally
307# produce a pass among all the failures.
308
309AT_SETUP([[Fatal errors but M4 continues producing output]])
310
311AT_DATA([[gen-skel.pl]],
312[[use warnings;
313use strict;
314my $M4 = "m4";
315my $DNL = "d"."nl";
316print "${M4}_divert_push(0)$DNL\n";
317print '@output(@,@)', "\n";
318(print "garbage"x10, "\n") for (1..1000);
319print "${M4}_divert_pop(0)\n";
320]])
321AT_CHECK([[perl gen-skel.pl > skel.c || exit 77]])
322
323AT_DATA([[input.y]],
324[[%skeleton "./skel.c"
325%%
326start: ;
327]])
328
329AT_BISON_CHECK([[input.y]], [[1]], [[]],
330[[input.y: fatal error: too many arguments for @output directive in skeleton
331]])
332
333AT_CLEANUP