Skip to content

NFC: Fix python literal string errors in TestRunner.py #7504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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|%})")
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