]> git.saurik.com Git - bison.git/blame - tests/output.at
2007-11-08 Paolo Bonzini <bonzini@gnu.org>
[bison.git] / tests / output.at
CommitLineData
342b8b6e 1# Checking the output filenames. -*- Autotest -*-
279cabb6
JD
2# Copyright (C) 2000, 2001, 2002, 2005, 2006, 2007 Free Software Foundation,
3# Inc.
342b8b6e 4
f16b0819 5# This program is free software: you can redistribute it and/or modify
342b8b6e 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#
342b8b6e
AD
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#
342b8b6e 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/>.
342b8b6e
AD
17
18AT_BANNER([[Output file names.]])
19
20
7625ec2c
AD
21# AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES, [SHELLIO],
22# [ADDITIONAL-TESTS])
f1bbfcce 23# -----------------------------------------------------------------------------
342b8b6e 24m4_define([AT_CHECK_OUTPUT],
bd9d212b 25[AT_SETUP([[Output files: $2 $3 $5]])
7625ec2c
AD
26case "$1" in
27 */*) mkdir `echo "$1" | sed 's,/.*,,'`;;
28esac
342b8b6e
AD
29AT_DATA([$1],
30[[$2
31%%
bfcf1f3a 32foo: {};
342b8b6e
AD
33]])
34
f1bbfcce 35AT_CHECK([bison $3 $1 $5], 0)
342b8b6e 36AT_CHECK([ls $4], [], [ignore])
7625ec2c 37$6
d803322e 38AT_CLEANUP
342b8b6e
AD
39])
40
41AT_CHECK_OUTPUT([foo.y], [], [-dv],
02650b7f 42 [foo.output foo.tab.c foo.tab.h])
f1bbfcce 43AT_CHECK_OUTPUT([foo.y], [], [-dv],
02650b7f
PE
44 [foo.output foo.tab.c foo.tab.h],
45 [>&-])
342b8b6e 46AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
02650b7f 47 [foo.c foo.h foo.output])
342b8b6e 48AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
02650b7f 49 [foo.output foo.tab.c foo.tab.h])
342b8b6e 50AT_CHECK_OUTPUT([foo.y], [], [-dv -y],
02650b7f 51 [y.output y.tab.c y.tab.h])
342b8b6e 52AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar],
02650b7f 53 [bar.output bar.tab.c bar.tab.h])
342b8b6e 54AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],
35fe0834 55 [foo.c foo.dot foo.h foo.output])
342b8b6e
AD
56
57
58AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [],
02650b7f 59 [foo.output foo.tab.c foo.tab.h])
342b8b6e 60AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[],
02650b7f 61 [y.output y.tab.c y.tab.h])
342b8b6e 62
5e5d5415 63AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[],
02650b7f 64 [y.output y.tab.c y.tab.h])
5e5d5415 65
02975b9a
JD
66# Exercise %output and %file-prefix including deprecated `='
67AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [],
02650b7f 68 [bar.output bar.tab.c bar.tab.h])
951366c1 69AT_CHECK_OUTPUT([foo.y], [%output="bar.c" %defines %verbose %yacc],[],
02650b7f 70 [bar.output bar.c bar.h])
951366c1 71AT_CHECK_OUTPUT([foo.y],
02975b9a 72 [%file-prefix="baz" %output "bar.c" %defines %verbose %yacc],
02650b7f
PE
73 [],
74 [bar.output bar.c bar.h])
951366c1 75
342b8b6e
AD
76
77# Check priorities of extension control.
78AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [],
02650b7f 79 [foo.output foo.tab.cc foo.tab.hh])
342b8b6e
AD
80
81AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c],
02650b7f 82 [foo.c foo.h foo.output])
342b8b6e
AD
83
84AT_CHECK_OUTPUT([foo.yy], [],
02650b7f
PE
85 [--defines=foo.hpp -o foo.c++],
86 [foo.c++ foo.hpp])
342b8b6e 87
02975b9a
JD
88AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"],
89 [-o foo.c++],
90 [foo.c++ foo.hpp])
91
342b8b6e 92AT_CHECK_OUTPUT([foo.yy], [],
02650b7f
PE
93 [-o foo.c++ --graph=foo.gph],
94 [foo.c++ foo.gph])
7625ec2c
AD
95
96
97## ------------ ##
98## C++ output. ##
99## ------------ ##
100
101m4_define([AT_CHECK_NO_SUBDIR_PART],
102[# Also make sure that the includes do not refer to the subdirectory.
103AT_CHECK([grep 'include .subdir/' $1.cc], 1, [])
104AT_CHECK([grep 'include .subdir/' $1.hh], 1, [])
105])
106
107AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
02650b7f 108 [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh])
7625ec2c
AD
109
110AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
02650b7f
PE
111 [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh],
112 [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
7625ec2c
AD
113
114AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose],
115 [-o subdir/foo.cc],
02650b7f 116 [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh],
7625ec2c 117 [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
3f7ca628
JD
118
119
120# AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR)
121# -----------------------------------------------------------------------------
122m4_define([AT_CHECK_CONFLICTING_OUTPUT],
123[AT_SETUP([Conflicting output files: $2 $3])
124case "$1" in
125 */*) mkdir `echo "$1" | sed 's,/.*,,'`;;
126esac
127AT_DATA([$1],
128[[$2
129%%
130foo: {};
131]])
132
133AT_CHECK([bison $3 $1], 0, [], [$4])
134AT_CLEANUP
135])
136
137AT_CHECK_CONFLICTING_OUTPUT([foo.y],
138[], [--graph="foo.tab.c"],
139[foo.y: warning: conflicting outputs to file `foo.tab.c'
140])
141
142AT_CHECK_CONFLICTING_OUTPUT([foo.y],
143[%defines "foo.output"], [-v],
144[foo.y: warning: conflicting outputs to file `foo.output'
145])
146
147AT_CHECK_CONFLICTING_OUTPUT([foo.y],
148[%skeleton "lalr1.cc" %defines], [--graph="location.hh"],
149[foo.y: warning: conflicting outputs to file `location.hh'
150])
bd9d212b
JD
151
152
153# AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
154# -----------------------------------------------------------------------------
155m4_define([AT_CHECK_OUTPUT_FILE_NAME],
156[AT_SETUP([Output file name: $1])
157
ce3448d5 158AT_DATA_GRAMMAR([glr.y],
bd9d212b
JD
159[[%glr-parser
160%code {
161 int yylex (void);
162 void yyerror (const char *);
163}
164%%
165start: {};
166]])
167AT_CHECK([bison -o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" glr.y])
168AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
169AT_COMPILE([glr.o], [-c "AS_ESCAPE([$1.c])"])
170$2
171
ce3448d5 172AT_DATA_GRAMMAR([cxx.y],
bd9d212b
JD
173[[%skeleton "lalr1.cc"
174%code { int yylex (yy::parser::semantic_type*); }
175%%
176start: {};
177]])
178AT_CHECK([bison -o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" cxx.y])
179AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
180AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.c])"])
181$2
182
183AT_CLEANUP
184])
185
186# Notice that the header file name here cannot contain
187# `"' since FILENAME in `#include "FILENAME"' cannot.
188AT_CHECK_OUTPUT_FILE_NAME([[`~!@#$%^&*()-=_+{}[]|\:;<>, .']])
189AT_CHECK_OUTPUT_FILE_NAME([[(]])
190AT_CHECK_OUTPUT_FILE_NAME([[)]])
191AT_CHECK_OUTPUT_FILE_NAME([[#]])
192AT_CHECK_OUTPUT_FILE_NAME([[@@]])
193AT_CHECK_OUTPUT_FILE_NAME([[@{]])
194AT_CHECK_OUTPUT_FILE_NAME([[@}]])
bd9d212b
JD
195AT_CHECK_OUTPUT_FILE_NAME([[@<:@]])
196AT_CHECK_OUTPUT_FILE_NAME([[@:>@]])