summaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2019-05-26 16:55:18 +0200
committerAkim Demaille <akim.demaille@gmail.com>2019-05-29 08:26:20 +0200
commit65126716d7c1b4f54761d34d813a61eb8649caea (patch)
tree5ced199e28df393d5fc4f46afcaefd679ce906fa /build-aux
parent1dcd6068dd3cbd5fd8e041fd6351651b0bdb84ef (diff)
downloadbison-65126716d7c1b4f54761d34d813a61eb8649caea.tar.gz
update-test: some file names have dashes in them
* build-aux/update-test (log): Rename as... (trace): this, to avoid clashes with the log variable. (getargs): Clarify the type of the arguments.
Diffstat (limited to 'build-aux')
-rwxr-xr-xbuild-aux/update-test25
1 files changed, 13 insertions, 12 deletions
diff --git a/build-aux/update-test b/build-aux/update-test
index fc7ed701..cf275a20 100755
--- a/build-aux/update-test
+++ b/build-aux/update-test
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# usage:
-# update-test _build/8d/tests/testsuite.dir/*.testsuite.log
+# update-test _build/8d/tests/testsuite.dir/*/testsuite.log
import argparse
import os
@@ -11,8 +11,8 @@ import re
def getargs():
p = argparse.ArgumentParser(description='Update test cases.')
opt = p.add_argument
- opt('tests', metavar='test', nargs='+', type=str, default=None,
- help='test files to update')
+ 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()
@@ -21,14 +21,14 @@ args = getargs()
subst = dict()
-def log(*args_):
+def trace(*args_):
if args.verbose:
print(*args_)
def contents(file):
'''The contents of a file.'''
- log(file)
+ trace(file)
f = open(file)
return f.read()
@@ -60,9 +60,9 @@ def diff_to_re(match):
def update(at_file, logfile):
test = contents(at_file)
if os.path.isfile(logfile):
- log("LOG: ", logfile)
+ trace("LOG: ", logfile)
l = contents(logfile)
- log("LOG: ", l)
+ trace("LOG: ", l)
global subst
subst = {}
re.sub(r'(?:^@@.*\n)((?:^[-+ ].*\n)+)',
@@ -71,7 +71,7 @@ def update(at_file, logfile):
if subst:
# Turn "subst{frm} -> to" into a large RE.
frm = '|'.join([re.escape(x) for x in subst])
- log("FROM:", frm)
+ trace("FROM:", frm)
test = re.sub("(" + frm + ")",
lambda m: subst[m.group(1)],
test, flags=re.MULTILINE)
@@ -81,13 +81,14 @@ def update(at_file, logfile):
def process(logfile):
log = contents(logfile)
# Look for the file to update.
- m = re.search(r'^\d+\. (\w+\.at):\d+: ', log, re.MULTILINE)
+ 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 t in args.tests:
- log("FILE:", t)
- process(t)
+for logfile in args.logs:
+ trace("FILE:", logfile)
+ process(logfile)