]> git.saurik.com Git - bison.git/blame_incremental - tests/output.at
Provide an additional sub-message for clarity.
[bison.git] / tests / output.at
... / ...
CommitLineData
1# Checking the output filenames. -*- Autotest -*-
2# Copyright (C) 2000, 2001, 2002, 2005, 2006, 2007, 2008, 2009 Free
3# Software 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
18AT_BANNER([[Output file names.]])
19
20
21# AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES, [SHELLIO],
22# [ADDITIONAL-TESTS])
23# -----------------------------------------------------------------------------
24m4_define([AT_CHECK_OUTPUT],
25[AT_SETUP([[Output files: $2 $3 $5]])
26for file in $1 $4; do
27 case "$file" in
28 */*) mkdir -p `echo "$file" | sed 's,/.*,,'`;;
29 esac
30done
31AT_DATA([$1],
32[[$2
33%%
34foo: {};
35]])
36
37AT_BISON_CHECK([$3 $1 $5], 0)
38AT_CHECK([ls $4], [], [ignore])
39$6
40AT_CLEANUP
41])
42
43AT_CHECK_OUTPUT([foo.y], [], [-dv],
44 [foo.output foo.tab.c foo.tab.h])
45AT_CHECK_OUTPUT([foo.y], [], [-dv],
46 [foo.output foo.tab.c foo.tab.h],
47 [>&-])
48AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
49 [foo.c foo.h foo.output])
50AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
51 [foo.output foo.tab.c foo.tab.h])
52AT_CHECK_OUTPUT([foo.y], [], [-dv -y],
53 [y.output y.tab.c y.tab.h])
54AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar],
55 [bar.output bar.tab.c bar.tab.h])
56AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],
57 [foo.c foo.dot foo.h foo.output])
58
59
60AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [],
61 [foo.output foo.tab.c foo.tab.h])
62AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[],
63 [y.output y.tab.c y.tab.h])
64
65AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[],
66 [y.output y.tab.c y.tab.h])
67
68# Exercise %output and %file-prefix including deprecated `='
69AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [],
70 [bar.output bar.tab.c bar.tab.h])
71AT_CHECK_OUTPUT([foo.y], [%output="bar.c" %defines %verbose %yacc],[],
72 [bar.output bar.c bar.h])
73AT_CHECK_OUTPUT([foo.y],
74 [%file-prefix="baz" %output "bar.c" %defines %verbose %yacc],
75 [],
76 [bar.output bar.c bar.h])
77
78
79# Check priorities of extension control.
80AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [],
81 [foo.output foo.tab.cc foo.tab.hh])
82
83AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c],
84 [foo.c foo.h foo.output])
85
86AT_CHECK_OUTPUT([foo.yy], [],
87 [--defines=foo.hpp -o foo.c++],
88 [foo.c++ foo.hpp])
89
90AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"],
91 [-o foo.c++],
92 [foo.c++ foo.hpp])
93
94AT_CHECK_OUTPUT([foo.yy], [],
95 [-o foo.c++ --graph=foo.gph],
96 [foo.c++ foo.gph])
97
98
99## ------------ ##
100## C++ output. ##
101## ------------ ##
102
103m4_define([AT_CHECK_NO_SUBDIR_PART],
104[# Also make sure that the includes do not refer to the subdirectory.
105AT_CHECK([grep 'include .subdir/' $1.cc], 1, [])
106AT_CHECK([grep 'include .subdir/' $1.hh], 1, [])
107])
108
109AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
110 [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh])
111
112AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
113 [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh],
114 [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
115
116AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose],
117 [-o subdir/foo.cc],
118 [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh],
119 [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
120
121AT_CHECK_OUTPUT([gram_dir/foo.yy],
122 [%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"],
123 [],
124 [output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/location.hh output_dir/stack.hh output_dir/position.hh])
125
126
127# AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR,
128# [EXIT-STATUS])
129# ------------------------------------------------------------------
130m4_define([AT_CHECK_CONFLICTING_OUTPUT],
131[AT_SETUP([Conflicting output files: $2 $3])
132case "$1" in
133 */*) mkdir `echo "$1" | sed 's,/.*,,'`;;
134esac
135AT_DATA([$1],
136[[$2
137%%
138foo: {};
139]])
140
141AT_BISON_CHECK([$3 $1], $5, [], [$4])
142AT_CLEANUP
143])
144
145AT_CHECK_CONFLICTING_OUTPUT([foo.y],
146[], [--graph="foo.tab.c"],
147[foo.y: warning: conflicting outputs to file `foo.tab.c'
148])
149
150AT_CHECK_CONFLICTING_OUTPUT([foo.y],
151[%defines "foo.output"], [-v],
152[foo.y: warning: conflicting outputs to file `foo.output'
153])
154
155AT_CHECK_CONFLICTING_OUTPUT([foo.y],
156[%skeleton "lalr1.cc" %defines], [--graph="location.hh"],
157[foo.y: warning: conflicting outputs to file `location.hh'
158])
159
160AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y],
161[foo.y: fatal error: refusing to overwrite the input file `foo.y'
162], 1)
163
164
165# AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
166# -----------------------------------------------------------------------------
167m4_define([AT_CHECK_OUTPUT_FILE_NAME],
168[AT_SETUP([Output file name: $1])
169
170AT_DATA_GRAMMAR([glr.y],
171[[%glr-parser
172%code {
173 int yylex (void);
174 void yyerror (const char *);
175}
176%%
177start: {};
178]])
179AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" glr.y])
180AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
181AT_COMPILE([glr.o], [-c "AS_ESCAPE([$1.c])"])
182$2
183
184AT_DATA_GRAMMAR([cxx.y],
185[[%skeleton "lalr1.cc"
186%code { int yylex (yy::parser::semantic_type*); }
187%%
188start: {};
189]])
190AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" cxx.y])
191AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
192AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.c])"])
193$2
194
195AT_CLEANUP
196])
197
198# Notice that the header file name here cannot contain
199# `"' since FILENAME in `#include "FILENAME"' cannot.
200AT_CHECK_OUTPUT_FILE_NAME([[`~!@#$%^&*()-=_+{}[]|\:;<>, .']])
201dnl Work around a bug in m4_expand that broke AT_SETUP in autoconf 2.62,
202dnl by using the definition from 2.63.
203m4_version_prereq([2.63], [],
204[m4_define([m4_expand], [_$0(-=<{($1)}>=-)])
205m4_define([_m4_expand],
206[m4_changequote([-=<{(], [)}>=-])$1m4_changequote([, ])])])
207AT_CHECK_OUTPUT_FILE_NAME([[(]])
208AT_CHECK_OUTPUT_FILE_NAME([[)]])
209AT_CHECK_OUTPUT_FILE_NAME([[@%:@]])
210AT_CHECK_OUTPUT_FILE_NAME([[@@]])
211AT_CHECK_OUTPUT_FILE_NAME([[@{]])
212AT_CHECK_OUTPUT_FILE_NAME([[@}]])
213AT_CHECK_OUTPUT_FILE_NAME([[@<:@]])
214AT_CHECK_OUTPUT_FILE_NAME([[@:>@]])