summaryrefslogtreecommitdiff
path: root/utils/lit
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2013-08-14 05:07:04 +0000
committerDaniel Dunbar <daniel@zuster.org>2013-08-14 05:07:04 +0000
commit5403214852da123d09b91377ad0fa4543afc816c (patch)
tree0f22e7d14ebfdb24eaeeadf1ec6ab945960a7cb9 /utils/lit
parent493e8d4bf503c8f573e0dce95ea146d181c623c6 (diff)
downloadllvm-5403214852da123d09b91377ad0fa4543afc816c.tar.gz
llvm-5403214852da123d09b91377ad0fa4543afc816c.tar.bz2
llvm-5403214852da123d09b91377ad0fa4543afc816c.tar.xz
[lit] Factor ShTest format script command parsing from other processing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188357 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/lit')
-rw-r--r--utils/lit/lit/TestRunner.py49
1 files changed, 32 insertions, 17 deletions
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
index 54bbd68893..fb724c9cdf 100644
--- a/utils/lit/lit/TestRunner.py
+++ b/utils/lit/lit/TestRunner.py
@@ -309,6 +309,25 @@ def isExpectedFail(test, xfails):
return False
+def parseIntegratedTestScriptCommands(sourcepath):
+ """
+ parseIntegratedTestScriptCommands(source_path) -> commands
+
+ Parse the commands in an integrated test script file into a list of
+ (line_number, command_type, line).
+ """
+ line_number = 0
+ for ln in open(sourcepath):
+ line_number += 1
+ if 'RUN:' in ln:
+ yield (line_number, 'RUN', ln[ln.index('RUN:')+4:])
+ elif 'XFAIL:' in ln:
+ yield (line_number, 'XFAIL', ln[ln.index('XFAIL:') + 6:])
+ elif 'REQUIRES:' in ln:
+ yield (line_number, 'REQUIRES', ln[ln.index('REQUIRES:') + 9:])
+ elif 'END.' in ln:
+ yield (line_number, 'END', ln[ln.index('END.') + 4:])
+
def parseIntegratedTestScript(test, normalize_slashes=False,
extra_substitutions=[]):
"""parseIntegratedTestScript - Scan an LLVM/Clang style integrated test
@@ -359,14 +378,9 @@ def parseIntegratedTestScript(test, normalize_slashes=False,
script = []
xfails = []
requires = []
- line_number = 0
- for ln in open(sourcepath):
- line_number += 1
- if 'RUN:' in ln:
- # Isolate the command to run.
- index = ln.index('RUN:')
- ln = ln[index+4:]
-
+ for line_number, command_type, ln in \
+ parseIntegratedTestScriptCommands(sourcepath):
+ if command_type == 'RUN':
# Trim trailing whitespace.
ln = ln.rstrip()
@@ -384,16 +398,17 @@ def parseIntegratedTestScript(test, normalize_slashes=False,
script[-1] = script[-1][:-1] + ln
else:
script.append(ln)
- elif 'XFAIL:' in ln:
- items = ln[ln.index('XFAIL:') + 6:].split(',')
- xfails.extend([s.strip() for s in items])
- elif 'REQUIRES:' in ln:
- items = ln[ln.index('REQUIRES:') + 9:].split(',')
- requires.extend([s.strip() for s in items])
- elif 'END.' in ln:
- # Check for END. lines.
- if ln[ln.index('END.'):].strip() == 'END.':
+ elif command_type == 'XFAIL':
+ xfails.extend([s.strip() for s in ln.split(',')])
+ elif command_type == 'REQUIRES':
+ requires.extend([s.strip() for s in ln.split(',')])
+ elif command_type == 'END':
+ # END commands are only honored if the rest of the line is empty.
+ if not ln.strip():
break
+ else:
+ raise ValueError("unknown script command type: %r" % (
+ command_type,))
# Apply substitutions to the script. Allow full regular
# expression syntax. Replace each matching occurrence of regular