mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
Revert r188376, "[lit] Support parsing scripts with inconsistent or invalid encodings.", this doesn't work yet for bots using the internal shell.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188379 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
003f93f134
commit
14a5c695a9
@ -305,54 +305,24 @@ def isExpectedFail(test, xfails):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def parseIntegratedTestScriptCommands(source_path):
|
def parseIntegratedTestScriptCommands(sourcepath):
|
||||||
"""
|
"""
|
||||||
parseIntegratedTestScriptCommands(source_path) -> commands
|
parseIntegratedTestScriptCommands(source_path) -> commands
|
||||||
|
|
||||||
Parse the commands in an integrated test script file into a list of
|
Parse the commands in an integrated test script file into a list of
|
||||||
(line_number, command_type, line).
|
(line_number, command_type, line).
|
||||||
"""
|
"""
|
||||||
|
line_number = 0
|
||||||
# This code is carefully written to be dual compatible with Python 2.5+ and
|
for ln in open(sourcepath):
|
||||||
# Python 3 without requiring input files to always have valid codings. The
|
line_number += 1
|
||||||
# trick we use is to open the file in binary mode and use the regular
|
if 'RUN:' in ln:
|
||||||
# expression library to find the commands, with it scanning strings in
|
yield (line_number, 'RUN', ln[ln.index('RUN:')+4:])
|
||||||
# Python2 and bytes in Python3.
|
elif 'XFAIL:' in ln:
|
||||||
#
|
yield (line_number, 'XFAIL', ln[ln.index('XFAIL:') + 6:])
|
||||||
# Once we find a match, we do require each script line to be decodable to
|
elif 'REQUIRES:' in ln:
|
||||||
# ascii, so we convert the outputs to ascii before returning. This way the
|
yield (line_number, 'REQUIRES', ln[ln.index('REQUIRES:') + 9:])
|
||||||
# remaining code can work with "strings" agnostic of the executing Python
|
elif 'END.' in ln:
|
||||||
# version.
|
yield (line_number, 'END', ln[ln.index('END.') + 4:])
|
||||||
|
|
||||||
def to_bytes(str):
|
|
||||||
# Encode to Latin1 to get binary data.
|
|
||||||
return str.encode('ISO-8859-1')
|
|
||||||
keywords = ('RUN:', 'XFAIL:', 'REQUIRES:', 'END.')
|
|
||||||
keywords_re = re.compile(
|
|
||||||
to_bytes("(%s)(.*)\n" % ("|".join(k for k in keywords),)))
|
|
||||||
|
|
||||||
f = open(source_path, 'rb')
|
|
||||||
try:
|
|
||||||
# Read the entire file contents.
|
|
||||||
data = f.read()
|
|
||||||
|
|
||||||
# Iterate over the matches.
|
|
||||||
line_number = 1
|
|
||||||
last_match_position = 0
|
|
||||||
for match in keywords_re.finditer(data):
|
|
||||||
# Compute the updated line number by counting the intervening
|
|
||||||
# newlines.
|
|
||||||
match_position = match.start()
|
|
||||||
line_number += data.count(to_bytes('\n'), last_match_position,
|
|
||||||
match_position)
|
|
||||||
last_match_position = match_position
|
|
||||||
|
|
||||||
# Convert the keyword and line to ascii and yield the command.
|
|
||||||
keyword,ln = match.groups()
|
|
||||||
yield (line_number, keyword[:-1].decode('ascii'),
|
|
||||||
ln.decode('ascii'))
|
|
||||||
finally:
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
def parseIntegratedTestScript(test, normalize_slashes=False,
|
def parseIntegratedTestScript(test, normalize_slashes=False,
|
||||||
extra_substitutions=[]):
|
extra_substitutions=[]):
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
# RUN: true
|
|
||||||
|
|
||||||
# Here is a string that cannot be decoded in line mode: Â.
|
|
Loading…
Reference in New Issue
Block a user