Skip to content
Snippets Groups Projects
Commit 75bd5990 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

run-tests: add a dedicated 'isoptional' function

This is clearer than repeated manual call to to 'endswith'.

(This is a gratuitous cleanup that I made while investigating a bug).
parent 8510566b
No related branches found
No related tags found
No related merge requests found
......@@ -1306,6 +1306,11 @@
WARN_YES = 2
WARN_NO = 3
MARK_OPTIONAL = b" (?)\n"
def isoptional(line):
return line.endswith(MARK_OPTIONAL)
class TTest(Test):
"""A "t test" is a test backed by a .t file."""
......@@ -1660,7 +1665,7 @@
els.pop(i)
break
if el:
if el.endswith(b" (?)\n"):
if isoptional(el):
optional.append(i)
else:
m = optline.match(el)
......@@ -1700,7 +1705,7 @@
while expected.get(pos, None):
el = expected[pos].pop(0)
if el:
if not el.endswith(b" (?)\n"):
if not isoptional(el):
m = optline.match(el)
if m:
conditions = [c for c in m.group(2).split(b' ')]
......@@ -1773,5 +1778,5 @@
if el == l: # perfect match (fast)
return True, True
retry = False
if el.endswith(b" (?)\n"):
if isoptional(el):
retry = "retry"
......@@ -1777,5 +1782,5 @@
retry = "retry"
el = el[:-5] + b"\n"
el = el[:-len(MARK_OPTIONAL)] + b"\n"
else:
m = optline.match(el)
if m:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment