Skip to content

Commit

Permalink
[lit] Add %:[STpst] to represent paths without colons on Windows.
Browse files Browse the repository at this point in the history
Summary:
We need these variables to concatenate two absolute paths to construct
a valid path. Currently, %t\%t is, for example, expanded to C:\foo\C:\foo,
which is not a valid path because ":" is not a valid path character
on Windows. With this patch, %t will be expanded to C\foo.

Differential Revision: http://reviews.llvm.org/D19757

llvm-svn: 268168
  • Loading branch information
rui314 committed Apr 30, 2016
1 parent acc98ca commit 53aa9f2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions llvm/utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,24 @@ def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False):
('%/t', tmpBase.replace('\\', '/') + '.tmp'),
('%/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),
])
return substitutions

def applySubstitutions(script, substitutions):
Expand Down

0 comments on commit 53aa9f2

Please sign in to comment.