Commit bcec0132 authored by Stefan Behnel's avatar Stefan Behnel

make test runner bark at unknown tag names in test files

parent c994f01b
...@@ -299,20 +299,33 @@ def memoize(f): ...@@ -299,20 +299,33 @@ def memoize(f):
@memoize @memoize
def parse_tags(filepath): def parse_tags(filepath):
tags = defaultdict(list) tags = defaultdict(list)
parse_tag = re.compile(r'#\s*(\w+)\s*:(.*)$').match
f = io_open(filepath, encoding='ISO-8859-1', errors='ignore') f = io_open(filepath, encoding='ISO-8859-1', errors='ignore')
try: try:
for line in f: for line in f:
# ignore BOM-like bytes and whitespace # ignore BOM-like bytes and whitespace
line = line.lstrip(UTF8_BOM_BYTES).strip() line = line.lstrip(UTF8_BOM_BYTES).strip()
if not line: if not line:
if tags:
break # assume all tags are in one block
else:
continue continue
if line[0] != '#': if line[0] != '#':
break break
ix = line.find(':') parsed = parse_tag(line)
if ix != -1: if parsed:
tag = line[1:ix].strip() tag, values = parsed.groups()
values = line[ix+1:].split(',') if tag in ('coding', 'encoding'):
tags[tag].extend([value.strip() for value in values]) continue
if tag == 'tags':
tag = 'tag'
print("WARNING: test tags use the 'tag' directive, not 'tags' (%s)" % filepath)
if tag not in ('mode', 'tag', 'ticket', 'cython'):
print("WARNING: unknown test directive '%s' found (%s)" % (tag, filepath))
values = values.split(',')
tags[tag].extend(filter(None, [value.strip() for value in values]))
elif tags:
break # assume all tags are in one block
finally: finally:
f.close() f.close()
return tags return tags
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment