forked from OSchip/llvm-project
lit: Improve %: normalization.
The new scheme should match the normalization of embedded paths in linkrepro tar files. Differential Revision: https://reviews.llvm.org/D39023 llvm-svn: 316044
This commit is contained in:
parent
8eb7005e21
commit
c03ceb92ca
|
@ -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,22 +867,14 @@ def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False):
|
|||
('%/T', tmpDir.replace('\\', '/')),
|
||||
])
|
||||
|
||||
# "%:[STpst]" are paths without colons.
|
||||
if kIsWindows:
|
||||
# "%:[STpst]" are normalized paths without colons and without a leading
|
||||
# slash.
|
||||
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),
|
||||
('%:s', colonNormalizePath(sourcepath)),
|
||||
('%:S', colonNormalizePath(sourcedir)),
|
||||
('%:p', colonNormalizePath(sourcedir)),
|
||||
('%:t', colonNormalizePath(tmpBase + '.tmp')),
|
||||
('%:T', colonNormalizePath(tmpDir)),
|
||||
])
|
||||
return substitutions
|
||||
|
||||
|
|
Loading…
Reference in New Issue