summaryrefslogtreecommitdiff
path: root/utils/lit
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-10-17 23:46:34 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-10-17 23:46:34 +0000
commit1eb5c71a5bac4887e9754c45dc19fc84c4f8a1d5 (patch)
treebf87653555fe178467cf3b76a2a1ec1385ca680e /utils/lit
parent607acf30af82817768793e1f1a3cfa3b232e9773 (diff)
lit: Improve %: normalization.
The new scheme should match the normalization of embedded paths in linkrepro tar files. Differential Revision: https://reviews.llvm.org/D39023 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316044 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/lit')
-rw-r--r--utils/lit/lit/TestRunner.py33
1 files changed, 16 insertions, 17 deletions
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
index b874f9ee61b..4def05d8870 100644
--- a/utils/lit/lit/TestRunner.py
+++ b/utils/lit/lit/TestRunner.py
@@ -825,6 +825,13 @@ def getTempPaths(test):
tmpBase = os.path.join(tmpDir, execbase)
return tmpDir, tmpBase
+def colonNormalizePath(path):
+ if kIsWindows:
+ return re.sub(r'^(.):', r'\1', path.replace('\\', '/'))
+ else:
+ assert path[0] == '/'
+ return path[1:]
+
def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False):
sourcepath = test.getSourcePath()
sourcedir = os.path.dirname(sourcepath)
@@ -860,23 +867,15 @@ def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False):
('%/T', tmpDir.replace('\\', '/')),
])
- # "%:[STpst]" are paths without colons.
- if kIsWindows:
- substitutions.extend([
- ('%:s', re.sub(r'^(.):', r'\1', sourcepath)),
- ('%:S', re.sub(r'^(.):', r'\1', sourcedir)),
- ('%:p', re.sub(r'^(.):', r'\1', sourcedir)),
- ('%:t', re.sub(r'^(.):', r'\1', tmpBase) + '.tmp'),
- ('%:T', re.sub(r'^(.):', r'\1', tmpDir)),
- ])
- else:
- substitutions.extend([
- ('%:s', sourcepath),
- ('%:S', sourcedir),
- ('%:p', sourcedir),
- ('%:t', tmpBase + '.tmp'),
- ('%:T', tmpDir),
- ])
+ # "%:[STpst]" are normalized paths without colons and without a leading
+ # slash.
+ substitutions.extend([
+ ('%:s', colonNormalizePath(sourcepath)),
+ ('%:S', colonNormalizePath(sourcedir)),
+ ('%:p', colonNormalizePath(sourcedir)),
+ ('%:t', colonNormalizePath(tmpBase + '.tmp')),
+ ('%:T', colonNormalizePath(tmpDir)),
+ ])
return substitutions
def applySubstitutions(script, substitutions):