summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit1ba25a1e56a2d910ef002208a44f9678b3e667a7 (patch)
tree7912d39ca8485c82f714750f7ac6c01278369d3c /llvm/utils/lit
parent0a4a23ebac79990e3f5475ecb0c21986d786d3e7 (diff)
downloadbcm5719-llvm-1ba25a1e56a2d910ef002208a44f9678b3e667a7.tar.gz
bcm5719-llvm-1ba25a1e56a2d910ef002208a44f9678b3e667a7.zip
[lit] Factor ShTest format script command parsing from other processing.
llvm-svn: 188357
Diffstat (limited to 'llvm/utils/lit')
-rw-r--r--llvm/utils/lit/lit/TestRunner.py49
1 files changed, 32 insertions, 17 deletions
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 54bbd688934..fb724c9cdfc 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/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
OpenPOWER on IntegriCloud