mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
The name "$end" is nice in the report, in particular it avoids that pointed-rules (aka items) be too long. It also helps keeping them "standard". But it is bad in error messages, we should report "end of file" (or maybe "end of input", this is debatable). So, unless the user already defined the alias for the error token herself, make it "end of file". It should even be translated if the user already translated some tokens, so that there is now no strong reason to redefine the $end token. * src/output.c (prepare_symbol_names): Issue "end of file" instead of "$end". * data/skeletons/lalr1.java (yytnamerr_): Remove the renaming hack. * build-aux/update-test: Accept files with names containing a "+", such as c++.at. * tests/actions.at, tests/c++.at, tests/conflicts.at, * tests/glr-regression.at, tests/regression.at, tests/skeletons.at: Adjust.
116 lines
3.0 KiB
Python
Executable File
116 lines
3.0 KiB
Python
Executable File
#! /usr/bin/env python
|
|
|
|
# Update expectations in an Autotest test suite.
|
|
|
|
# Copyright (C) 2019-2020 Free Software Foundation, Inc.
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
#
|
|
# Written by Akim Demaille.
|
|
|
|
# usage:
|
|
#
|
|
# update-test _build/8d/tests/testsuite.dir/*/testsuite.log
|
|
#
|
|
# from your source tree.
|
|
import argparse
|
|
import os
|
|
import re
|
|
|
|
|
|
def getargs():
|
|
p = argparse.ArgumentParser(description='Update test cases.')
|
|
opt = p.add_argument
|
|
opt('logs', metavar='log', nargs='+', type=str, default=None,
|
|
help='log files to process')
|
|
opt('-v', '--verbose', action='store_true',
|
|
help='Be verbose')
|
|
return p.parse_args()
|
|
|
|
args = getargs()
|
|
subst = dict()
|
|
|
|
|
|
def trace(*args_):
|
|
if args.verbose:
|
|
print(*args_)
|
|
|
|
|
|
def contents(file):
|
|
'''The contents of a file.'''
|
|
trace(file)
|
|
f = open(file)
|
|
return f.read()
|
|
|
|
|
|
def diff_to_re(match):
|
|
'''Convert a portion of patch into a regex substitution to perform.
|
|
No longer used, we now use the expected/effective parts.
|
|
'''
|
|
frm = []
|
|
to = []
|
|
is_diff = False
|
|
for l in match.group(1).splitlines():
|
|
print(l)
|
|
# t in [-+ ]
|
|
t = l[0]
|
|
l = l[1:]
|
|
if t in ['-', ' ']:
|
|
is_diff = True
|
|
frm.append(l)
|
|
if t in ['+', ' ']:
|
|
is_diff = True
|
|
to.append(l)
|
|
if is_diff:
|
|
frm = "\n".join(frm)
|
|
to = "\n".join(to)
|
|
subst[frm] = to
|
|
|
|
|
|
def update(at_file, logfile):
|
|
test = contents(at_file)
|
|
if os.path.isfile(logfile):
|
|
trace("LOG: ", logfile)
|
|
l = contents(logfile)
|
|
trace("LOG: ", l)
|
|
global subst
|
|
subst = {}
|
|
re.sub(r'(?:^@@.*\n)((?:^[-+ ].*\n)+)',
|
|
diff_to_re, l, flags = re.MULTILINE)
|
|
print(subst)
|
|
if subst:
|
|
# Turn "subst{frm} -> to" into a large RE.
|
|
frm = '|'.join([re.escape(x) for x in subst])
|
|
trace("FROM:", frm)
|
|
test = re.sub("(" + frm + ")",
|
|
lambda m: subst[m.group(1)],
|
|
test, flags=re.MULTILINE)
|
|
open(at_file, 'w').write(test)
|
|
|
|
|
|
def process(logfile):
|
|
log = contents(logfile)
|
|
# Look for the file to update.
|
|
m = re.search(r'^\d+\. ([\-\+\w]+\.at):\d+: ', log, re.MULTILINE)
|
|
if not m:
|
|
trace("no diff found:", logfile)
|
|
return
|
|
at_file = 'tests/' + m.group(1)
|
|
print(at_file)
|
|
update(at_file, logfile)
|
|
|
|
for logfile in args.logs:
|
|
trace("FILE:", logfile)
|
|
process(logfile)
|