summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-06-11 23:27:45 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-06-11 23:27:45 +0000
commitf32a41a7e6df8ff5f78c673e3a73303bdba759ff (patch)
tree4f14f187c4243ae036e9af331eb0afa9631674a4 /utils
parent1114f568bc35cf13064c864df44194630449bec5 (diff)
downloadllvm-f32a41a7e6df8ff5f78c673e3a73303bdba759ff.tar.gz
llvm-f32a41a7e6df8ff5f78c673e3a73303bdba759ff.tar.bz2
llvm-f32a41a7e6df8ff5f78c673e3a73303bdba759ff.tar.xz
lit: When running Tcl style tests on Windows, substitute slashes to avoid Tcl
quoting problems. Not particularly ideal, but should work ok. Based on a patch by Michael Spencer! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105855 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/lit/lit/TestRunner.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
index d10e4b030d..c2a6e5bb38 100644
--- a/utils/lit/lit/TestRunner.py
+++ b/utils/lit/lit/TestRunner.py
@@ -13,11 +13,13 @@ class InternalShellError(Exception):
self.command = command
self.message = message
+kIsWindows = platform.system() == 'Windows'
+
# Don't use close_fds on Windows.
-kUseCloseFDs = platform.system() != 'Windows'
+kUseCloseFDs = not kIsWindows
# Use temporary files to replace /dev/null on Windows.
-kAvoidDevNull = platform.system() == 'Windows'
+kAvoidDevNull = kIsWindows
def executeCommand(command, cwd=None, env=None):
p = subprocess.Popen(command, cwd=cwd,
@@ -364,7 +366,7 @@ def isExpectedFail(xfails, xtargets, target_triple):
return True
-def parseIntegratedTestScript(test):
+def parseIntegratedTestScript(test, normalize_slashes):
"""parseIntegratedTestScript - Scan an LLVM/Clang style integrated test
script and extract the lines to 'RUN' as well as 'XFAIL' and 'XTARGET'
information. The RUN lines also will have variable substitution performed.
@@ -375,18 +377,25 @@ def parseIntegratedTestScript(test):
#
# FIXME: This should not be here?
sourcepath = test.getSourcePath()
+ sourcedir = os.path.dirname(sourcepath)
execpath = test.getExecPath()
execdir,execbase = os.path.split(execpath)
tmpBase = os.path.join(execdir, 'Output', execbase)
if test.index is not None:
tmpBase += '_%d' % test.index
+ # Normalize slashes, if requested.
+ if normalize_slashes:
+ sourcepath = sourcepath.replace('\\', '/')
+ sourcedir = sourcedir.replace('\\', '/')
+ tmpBase = tmpBase.replace('\\', '/')
+
# We use #_MARKER_# to hide %% while we do the other substitutions.
substitutions = [('%%', '#_MARKER_#')]
substitutions.extend(test.config.substitutions)
substitutions.extend([('%s', sourcepath),
- ('%S', os.path.dirname(sourcepath)),
- ('%p', os.path.dirname(sourcepath)),
+ ('%S', sourcedir),
+ ('%p', sourcedir),
('%t', tmpBase + '.tmp'),
# FIXME: Remove this once we kill DejaGNU.
('%abs_tmp', tmpBase + '.tmp'),
@@ -462,7 +471,9 @@ def executeTclTest(test, litConfig):
if test.config.unsupported:
return (Test.UNSUPPORTED, 'Test is unsupported')
- res = parseIntegratedTestScript(test)
+ # Parse the test script, normalizing slashes in substitutions on Windows
+ # (since otherwise Tcl style lexing will treat them as escapes).
+ res = parseIntegratedTestScript(test, normalize_slashes=kIsWindows)
if len(res) == 2:
return res