aboutsummaryrefslogtreecommitdiffstats
path: root/utils/lit
diff options
context:
space:
mode:
Diffstat (limited to 'utils/lit')
-rw-r--r--utils/lit/lit/LitConfig.py16
-rw-r--r--utils/lit/lit/TestFormats.py11
-rw-r--r--utils/lit/lit/TestRunner.py25
-rw-r--r--utils/lit/lit/TestingConfig.py2
-rw-r--r--utils/lit/lit/Util.py18
5 files changed, 59 insertions, 13 deletions
diff --git a/utils/lit/lit/LitConfig.py b/utils/lit/lit/LitConfig.py
index 43ed6f1..7ca1b9c 100644
--- a/utils/lit/lit/LitConfig.py
+++ b/utils/lit/lit/LitConfig.py
@@ -85,6 +85,22 @@ class LitConfig:
return self.bashPath
+ def getToolsPath(self, dir, paths, tools):
+ import os, Util
+ if dir is not None and os.path.isabs(dir) and os.path.isdir(dir):
+ if not Util.checkToolsPath(dir, tools):
+ return None
+ else:
+ dir = Util.whichTools(tools, paths)
+
+ # bash
+ self.bashPath = Util.which('bash', dir)
+ if self.bashPath is None:
+ self.warning("Unable to find 'bash.exe'.")
+ self.bashPath = ''
+
+ return dir
+
def _write_message(self, kind, message):
import inspect, os, sys
diff --git a/utils/lit/lit/TestFormats.py b/utils/lit/lit/TestFormats.py
index 7662e14..6dda2fd 100644
--- a/utils/lit/lit/TestFormats.py
+++ b/utils/lit/lit/TestFormats.py
@@ -1,15 +1,15 @@
import os
-import platform
+import sys
import Test
import TestRunner
import Util
-kIsWindows = platform.system() == 'Windows'
+kIsWindows = sys.platform in ['win32', 'cygwin']
class GoogleTest(object):
def __init__(self, test_sub_dir, test_suffix):
- self.test_sub_dir = str(test_sub_dir).split(';')
+ self.test_sub_dir = os.path.normcase(str(test_sub_dir)).split(';')
self.test_suffix = str(test_suffix)
# On Windows, assume tests will also end in '.exe'.
@@ -59,8 +59,9 @@ class GoogleTest(object):
source_path = testSuite.getSourcePath(path_in_suite)
for filename in os.listdir(source_path):
# Check for the one subdirectory (build directory) tests will be in.
- if not filename in self.test_sub_dir:
- continue
+ if not '.' in self.test_sub_dir:
+ if not os.path.normcase(filename) in self.test_sub_dir:
+ continue
filepath = os.path.join(source_path, filename)
if not os.path.isdir(filepath):
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
index a2f97cd..80d0ba1 100644
--- a/utils/lit/lit/TestRunner.py
+++ b/utils/lit/lit/TestRunner.py
@@ -8,6 +8,8 @@ import Util
import platform
import tempfile
+import re
+
class InternalShellError(Exception):
def __init__(self, command, message):
self.command = command
@@ -335,23 +337,28 @@ def executeTclScriptInternal(test, litConfig, tmpBase, commands, cwd):
return out, err, exitCode
def executeScript(test, litConfig, tmpBase, commands, cwd):
+ bashPath = litConfig.getBashPath();
+ isWin32CMDEXE = (litConfig.isWindows and not bashPath)
script = tmpBase + '.script'
- if litConfig.isWindows:
+ if isWin32CMDEXE:
script += '.bat'
# Write script file
f = open(script,'w')
- if litConfig.isWindows:
+ if isWin32CMDEXE:
f.write('\nif %ERRORLEVEL% NEQ 0 EXIT\n'.join(commands))
else:
f.write(' &&\n'.join(commands))
f.write('\n')
f.close()
- if litConfig.isWindows:
+ if isWin32CMDEXE:
command = ['cmd','/c', script]
else:
- command = ['/bin/sh', script]
+ if bashPath:
+ command = [bashPath, script]
+ else:
+ command = ['/bin/sh', script]
if litConfig.useValgrind:
# FIXME: Running valgrind on sh is overkill. We probably could just
# run on clang with no real loss.
@@ -444,11 +451,15 @@ def parseIntegratedTestScript(test, normalize_slashes=False):
if ln[ln.index('END.'):].strip() == 'END.':
break
- # Apply substitutions to the script.
+ # 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:
- ln = ln.replace(a,b)
+ if kIsWindows:
+ b = b.replace("\\","\\\\")
+ ln = re.sub(a, b, ln)
# Strip the trailing newline and any extra whitespace.
return ln.strip()
@@ -547,7 +558,7 @@ def executeShTest(test, litConfig, useExternalSh):
if test.config.unsupported:
return (Test.UNSUPPORTED, 'Test is unsupported')
- res = parseIntegratedTestScript(test)
+ res = parseIntegratedTestScript(test, useExternalSh)
if len(res) == 2:
return res
diff --git a/utils/lit/lit/TestingConfig.py b/utils/lit/lit/TestingConfig.py
index 440375a..c7a03dd 100644
--- a/utils/lit/lit/TestingConfig.py
+++ b/utils/lit/lit/TestingConfig.py
@@ -17,6 +17,8 @@ class TestingConfig:
'PATHEXT' : os.environ.get('PATHEXT',''),
'SYSTEMROOT' : os.environ.get('SYSTEMROOT',''),
'LLVM_DISABLE_CRT_DEBUG' : '1',
+ 'PRINTF_EXPONENT_DIGITS' : '2',
+ 'PYTHONUNBUFFERED' : '1',
}
config = TestingConfig(parent,
diff --git a/utils/lit/lit/Util.py b/utils/lit/lit/Util.py
index 414b714..5635f50 100644
--- a/utils/lit/lit/Util.py
+++ b/utils/lit/lit/Util.py
@@ -64,7 +64,11 @@ def which(command, paths = None):
paths = os.defpath
# Get suffixes to search.
- pathext = os.environ.get('PATHEXT', '').split(os.pathsep)
+ # On Cygwin, 'PATHEXT' may exist but it should not be used.
+ if os.pathsep == ';':
+ pathext = os.environ.get('PATHEXT', '').split(';')
+ else:
+ pathext = ['']
# Search the paths...
for path in paths.split(os.pathsep):
@@ -75,6 +79,18 @@ def which(command, paths = None):
return None
+def checkToolsPath(dir, tools):
+ for tool in tools:
+ if not os.path.exists(os.path.join(dir, tool)):
+ return False;
+ return True;
+
+def whichTools(tools, paths):
+ for path in paths.split(os.pathsep):
+ if checkToolsPath(path, tools):
+ return path
+ return None
+
def printHistogram(items, title = 'Items'):
import itertools, math