summaryrefslogtreecommitdiffstats
path: root/llvm/utils/lit
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-10-28 02:36:45 +0000
committerMatthias Braun <matze@braunis.de>2015-10-28 02:36:45 +0000
commita0ac8e4411fbc418c930e793022682a0bb9105f2 (patch)
treecb62b73e23a6814dde599ea585bd7a64a5c3190a /llvm/utils/lit
parent869f60b8068e03cd027084015cb543367844fa67 (diff)
downloadbcm5719-llvm-a0ac8e4411fbc418c930e793022682a0bb9105f2.tar.gz
bcm5719-llvm-a0ac8e4411fbc418c930e793022682a0bb9105f2.zip
lit/TestRunner.py: Factor variable subsitution into an own function; NFCI
This is a clearer separation of concerns and makes it easier to reuse the function. llvm-svn: 251481
Diffstat (limited to 'llvm/utils/lit')
-rw-r--r--llvm/utils/lit/lit/TestRunner.py51
1 files changed, 26 insertions, 25 deletions
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 94bd73a38a4..78a4fa8e65b 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -456,13 +456,27 @@ def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False):
])
return substitutions
-def parseIntegratedTestScript(test, substitutions, require_script=True):
+def applySubstitutions(script, substitutions):
+ """Apply substitutions to the script. Allow full regular expression syntax.
+ Replace each matching occurrence of regular expression pattern a with
+ substitution b in line ln."""
+ def processLine(ln):
+ # Apply substitutions
+ for a,b in substitutions:
+ if kIsWindows:
+ b = b.replace("\\","\\\\")
+ ln = re.sub(a, b, ln)
+
+ # Strip the trailing newline and any extra whitespace.
+ return ln.strip()
+ return map(processLine, script)
+
+def parseIntegratedTestScript(test, require_script=True):
"""parseIntegratedTestScript - Scan an LLVM/Clang style integrated test
script and extract the lines to 'RUN' as well as 'XFAIL' and 'REQUIRES'
- and 'UNSUPPORTED' information. The RUN lines also will have variable
- substitution performed. If 'require_script' is False an empty script may be
- returned. This can be used for test formats where the actual script is
- optional or ignored.
+ and 'UNSUPPORTED' information. If 'require_script' is False an empty script
+ may be returned. This can be used for test formats where the actual script
+ is optional or ignored.
"""
# Collect the test lines from the script.
sourcepath = test.getSourcePath()
@@ -504,21 +518,6 @@ def parseIntegratedTestScript(test, substitutions, require_script=True):
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
- # expression pattern a with substitution b in line ln.
- def processLine(ln):
- # Apply substitutions
- for a,b in substitutions:
- if kIsWindows:
- b = b.replace("\\","\\\\")
- ln = re.sub(a, b, ln)
-
- # Strip the trailing newline and any extra whitespace.
- return ln.strip()
- script = [processLine(ln)
- for ln in script]
-
# Verify the script contains a run line.
if require_script and not script:
return lit.Test.Result(Test.UNRESOLVED, "Test has no run line!")
@@ -596,16 +595,18 @@ def executeShTest(test, litConfig, useExternalSh,
if test.config.unsupported:
return (Test.UNSUPPORTED, 'Test is unsupported')
- tmpDir, tmpBase = getTempPaths(test)
- substitutions = list(extra_substitutions)
- substitutions += getDefaultSubstitutions(test, tmpDir, tmpBase,
- normalize_slashes=useExternalSh)
- script = parseIntegratedTestScript(test, substitutions)
+ script = parseIntegratedTestScript(test)
if isinstance(script, lit.Test.Result):
return script
if litConfig.noExecute:
return lit.Test.Result(Test.PASS)
+ tmpDir, tmpBase = getTempPaths(test)
+ substitutions = list(extra_substitutions)
+ substitutions += getDefaultSubstitutions(test, tmpDir, tmpBase,
+ normalize_slashes=useExternalSh)
+ script = applySubstitutions(script, substitutions)
+
# Re-run failed tests up to test_retry_attempts times.
attempts = 1
if hasattr(test.config, 'test_retry_attempts'):
OpenPOWER on IntegriCloud