scripts: Fixed several SyntaxWarning for python test helpers
Many of these require a r'' string context to avoid errors like: scripts/test.py:105: SyntaxWarning: invalid escape sequence '\s'
This commit is contained in:
@@ -35,10 +35,10 @@ LEXEMES = {
|
|||||||
'assert': ['assert'],
|
'assert': ['assert'],
|
||||||
'arrow': ['=>'],
|
'arrow': ['=>'],
|
||||||
'string': [r'"(?:\\.|[^"])*"', r"'(?:\\.|[^'])\'"],
|
'string': [r'"(?:\\.|[^"])*"', r"'(?:\\.|[^'])\'"],
|
||||||
'paren': ['\(', '\)'],
|
'paren': [r'\(', r'\)'],
|
||||||
'cmp': CMP.keys(),
|
'cmp': CMP.keys(),
|
||||||
'logic': ['\&\&', '\|\|'],
|
'logic': [r'\&\&', r'\|\|'],
|
||||||
'sep': [':', ';', '\{', '\}', ','],
|
'sep': [':', ';', r'\{', r'\}', ','],
|
||||||
'op': ['->'], # specifically ops that conflict with cmp
|
'op': ['->'], # specifically ops that conflict with cmp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+19
-19
@@ -102,9 +102,9 @@ class TestCase:
|
|||||||
# the runner itself.
|
# the runner itself.
|
||||||
for v_ in csplit(v):
|
for v_ in csplit(v):
|
||||||
m = re.search(r'\brange\b\s*\('
|
m = re.search(r'\brange\b\s*\('
|
||||||
'(?P<start>[^,\s]*)'
|
r'(?P<start>[^,\s]*)'
|
||||||
'\s*(?:,\s*(?P<stop>[^,\s]*)'
|
r'\s*(?:,\s*(?P<stop>[^,\s]*)'
|
||||||
'\s*(?:,\s*(?P<step>[^,\s]*)\s*)?)?\)',
|
r'\s*(?:,\s*(?P<step>[^,\s]*)\s*)?)?\)',
|
||||||
v_)
|
v_)
|
||||||
if m:
|
if m:
|
||||||
start = (int(m.group('start'), 0)
|
start = (int(m.group('start'), 0)
|
||||||
@@ -163,8 +163,8 @@ class TestSuite:
|
|||||||
code_linenos = []
|
code_linenos = []
|
||||||
for i, line in enumerate(f):
|
for i, line in enumerate(f):
|
||||||
match = re.match(
|
match = re.match(
|
||||||
'(?P<case>\[\s*cases\s*\.\s*(?P<name>\w+)\s*\])'
|
r'(?P<case>\[\s*cases\s*\.\s*(?P<name>\w+)\s*\])'
|
||||||
'|' '(?P<code>code\s*=)',
|
r'|' r'(?P<code>code\s*=)',
|
||||||
line)
|
line)
|
||||||
if match and match.group('case'):
|
if match and match.group('case'):
|
||||||
case_linenos.append((i+1, match.group('name')))
|
case_linenos.append((i+1, match.group('name')))
|
||||||
@@ -602,9 +602,9 @@ def find_perms(runner_, ids=[], **args):
|
|||||||
errors='replace',
|
errors='replace',
|
||||||
close_fds=False)
|
close_fds=False)
|
||||||
pattern = re.compile(
|
pattern = re.compile(
|
||||||
'^(?P<case>[^\s]+)'
|
r'^(?P<case>[^\s]+)'
|
||||||
'\s+(?P<flags>[^\s]+)'
|
r'\s+(?P<flags>[^\s]+)'
|
||||||
'\s+(?P<filtered>\d+)/(?P<perms>\d+)')
|
r'\s+(?P<filtered>\d+)/(?P<perms>\d+)')
|
||||||
# skip the first line
|
# skip the first line
|
||||||
for line in it.islice(proc.stdout, 1, None):
|
for line in it.islice(proc.stdout, 1, None):
|
||||||
m = pattern.match(line)
|
m = pattern.match(line)
|
||||||
@@ -632,8 +632,8 @@ def find_perms(runner_, ids=[], **args):
|
|||||||
errors='replace',
|
errors='replace',
|
||||||
close_fds=False)
|
close_fds=False)
|
||||||
pattern = re.compile(
|
pattern = re.compile(
|
||||||
'^(?P<case>[^\s]+)'
|
r'^(?P<case>[^\s]+)'
|
||||||
'\s+(?P<path>[^:]+):(?P<lineno>\d+)')
|
r'\s+(?P<path>[^:]+):(?P<lineno>\d+)')
|
||||||
# skip the first line
|
# skip the first line
|
||||||
for line in it.islice(proc.stdout, 1, None):
|
for line in it.islice(proc.stdout, 1, None):
|
||||||
m = pattern.match(line)
|
m = pattern.match(line)
|
||||||
@@ -676,8 +676,8 @@ def find_path(runner_, id, **args):
|
|||||||
errors='replace',
|
errors='replace',
|
||||||
close_fds=False)
|
close_fds=False)
|
||||||
pattern = re.compile(
|
pattern = re.compile(
|
||||||
'^(?P<case>[^\s]+)'
|
r'^(?P<case>[^\s]+)'
|
||||||
'\s+(?P<path>[^:]+):(?P<lineno>\d+)')
|
r'\s+(?P<path>[^:]+):(?P<lineno>\d+)')
|
||||||
# skip the first line
|
# skip the first line
|
||||||
for line in it.islice(proc.stdout, 1, None):
|
for line in it.islice(proc.stdout, 1, None):
|
||||||
m = pattern.match(line)
|
m = pattern.match(line)
|
||||||
@@ -706,7 +706,7 @@ def find_defines(runner_, id, **args):
|
|||||||
errors='replace',
|
errors='replace',
|
||||||
close_fds=False)
|
close_fds=False)
|
||||||
defines = co.OrderedDict()
|
defines = co.OrderedDict()
|
||||||
pattern = re.compile('^(?P<define>\w+)=(?P<value>.+)')
|
pattern = re.compile(r'^(?P<define>\w+)=(?P<value>.+)')
|
||||||
for line in proc.stdout:
|
for line in proc.stdout:
|
||||||
m = pattern.match(line)
|
m = pattern.match(line)
|
||||||
if m:
|
if m:
|
||||||
@@ -781,12 +781,12 @@ def run_stage(name, runner_, ids, stdout_, trace_, output_, **args):
|
|||||||
failures = []
|
failures = []
|
||||||
killed = False
|
killed = False
|
||||||
|
|
||||||
pattern = re.compile('^(?:'
|
pattern = re.compile(r'^(?:'
|
||||||
'(?P<op>running|finished|skipped|powerloss) '
|
r'(?P<op>running|finished|skipped|powerloss) '
|
||||||
'(?P<id>(?P<case>[^:]+)[^\s]*)'
|
r'(?P<id>(?P<case>[^:]+)[^\s]*)'
|
||||||
'|' '(?P<path>[^:]+):(?P<lineno>\d+):(?P<op_>assert):'
|
r'|' r'(?P<path>[^:]+):(?P<lineno>\d+):(?P<op_>assert):'
|
||||||
' *(?P<message>.*)'
|
r' *(?P<message>.*)'
|
||||||
')$')
|
r')$')
|
||||||
locals = th.local()
|
locals = th.local()
|
||||||
children = set()
|
children = set()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user