Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ def parseIntegratedTestScript(test, normalize_slashes=False,
])

# re for %if
re_cond_end = re.compile('%{')
re_if = re.compile('(.*?)(?:%if)')
re_nested_if = re.compile('(.*?)(?:%if|%})')
re_else = re.compile('^\s*%else\s*(%{)?')
re_cond_end = re.compile("%{")
re_if = re.compile("(.*?)(?:%if)")
re_nested_if = re.compile("(.*?)(?:%if|%})")
Comment on lines +441 to +443
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use raw strings for all of these for consistency? I think it's more or less a best practice to always use raw strings for the input to re. functions.

re_else = re.compile(r"^\s*%else\s*(%{)?")


# Collect the test lines from the script.
Expand All @@ -455,13 +455,15 @@ def parseIntegratedTestScript(test, normalize_slashes=False,
ln = ln.rstrip()

# Substitute line number expressions
ln = re.sub('%\(line\)', str(line_number), ln)
ln = re.sub(r"%\(line\)", str(line_number), ln)

def replace_line_number(match):
if match.group(1) == '+':
return str(line_number + int(match.group(2)))
if match.group(1) == '-':
return str(line_number - int(match.group(2)))
ln = re.sub('%\(line *([\+-]) *(\d+)\)', replace_line_number, ln)

ln = re.sub(r"%\(line *([\+-]) *(\d+)\)", replace_line_number, ln)

# Collapse lines with trailing '\\'.
if script and script[-1][-1] == '\\':
Expand Down