aboutsummaryrefslogtreecommitdiffstats
path: root/utils/lit
diff options
context:
space:
mode:
Diffstat (limited to 'utils/lit')
-rw-r--r--utils/lit/MANIFEST.in2
-rw-r--r--utils/lit/README.txt8
-rw-r--r--utils/lit/lit/Test.py8
-rw-r--r--utils/lit/lit/TestingConfig.py24
-rw-r--r--utils/lit/lit/__init__.py2
-rw-r--r--utils/lit/lit/formats/googletest.py2
-rwxr-xr-xutils/lit/lit/main.py32
-rwxr-xr-xutils/lit/utils/check-sdist1
8 files changed, 65 insertions, 14 deletions
diff --git a/utils/lit/MANIFEST.in b/utils/lit/MANIFEST.in
index 6491a02..7a732b3 100644
--- a/utils/lit/MANIFEST.in
+++ b/utils/lit/MANIFEST.in
@@ -1,7 +1,9 @@
include TODO lit.py
recursive-include tests *
+recursive-include examples *
global-exclude *pyc
global-exclude *~
prune tests/Output
prune tests/*/Output
prune tests/*/*/Output
+prune tests/*/*/*/Output
diff --git a/utils/lit/README.txt b/utils/lit/README.txt
new file mode 100644
index 0000000..8cf4840
--- /dev/null
+++ b/utils/lit/README.txt
@@ -0,0 +1,8 @@
+===============================
+ lit - A Software Testing Tool
+===============================
+
+lit is a portable tool for executing LLVM and Clang style test suites,
+summarizing their results, and providing indication of failures. lit is designed
+to be a lightweight testing tool with as simple a user interface as possible.
+
diff --git a/utils/lit/lit/Test.py b/utils/lit/lit/Test.py
index b4988f5..e51bf12 100644
--- a/utils/lit/lit/Test.py
+++ b/utils/lit/lit/Test.py
@@ -128,10 +128,11 @@ class TestSuite:
class Test:
"""Test - Information on a single test instance."""
- def __init__(self, suite, path_in_suite, config):
+ def __init__(self, suite, path_in_suite, config, file_path = None):
self.suite = suite
self.path_in_suite = path_in_suite
self.config = config
+ self.file_path = file_path
# A list of conditions under which this test is expected to fail. These
# can optionally be provided by test format handlers, and will be
# honored when the test result is supplied.
@@ -157,6 +158,11 @@ class Test:
def getFullName(self):
return self.suite.config.name + ' :: ' + '/'.join(self.path_in_suite)
+ def getFilePath(self):
+ if self.file_path:
+ return self.file_path
+ return self.getSourcePath()
+
def getSourcePath(self):
return self.suite.getSourcePath(self.path_in_suite)
diff --git a/utils/lit/lit/TestingConfig.py b/utils/lit/lit/TestingConfig.py
index 4a34b77..eb89067 100644
--- a/utils/lit/lit/TestingConfig.py
+++ b/utils/lit/lit/TestingConfig.py
@@ -1,7 +1,7 @@
import os
import sys
-PY2 = sys.version_info[0] < 3
+OldPy = sys.version_info[0] == 2 and sys.version_info[1] < 7
class TestingConfig:
""""
@@ -38,7 +38,7 @@ class TestingConfig:
# The option to preserve TEMP, TMP, and TMPDIR.
# This is intended to check how many temporary files would be generated
# (and be not cleaned up) in automated builders.
- if os.environ.has_key('LIT_PRESERVES_TMP'):
+ if 'LIT_PRESERVES_TMP' in os.environ:
environment.update({
'TEMP' : os.environ.get('TEMP',''),
'TMP' : os.environ.get('TMP',''),
@@ -74,12 +74,14 @@ class TestingConfig:
"""
# Load the config script data.
- f = open(path)
- try:
- data = f.read()
- except:
- litConfig.fatal('unable to load config file: %r' % (path,))
- f.close()
+ data = None
+ if not OldPy:
+ f = open(path)
+ try:
+ data = f.read()
+ except:
+ litConfig.fatal('unable to load config file: %r' % (path,))
+ f.close()
# Execute the config script to initialize the object.
cfg_globals = dict(globals())
@@ -87,10 +89,10 @@ class TestingConfig:
cfg_globals['lit_config'] = litConfig
cfg_globals['__file__'] = path
try:
- if PY2:
- exec("exec data in cfg_globals")
+ if OldPy:
+ execfile(path, cfg_globals)
else:
- exec(data, cfg_globals)
+ exec(compile(data, path, 'exec'), cfg_globals, None)
if litConfig.debug:
litConfig.note('... loaded config %r' % path)
except SystemExit:
diff --git a/utils/lit/lit/__init__.py b/utils/lit/lit/__init__.py
index 3967fdd..46fa82d 100644
--- a/utils/lit/lit/__init__.py
+++ b/utils/lit/lit/__init__.py
@@ -5,7 +5,7 @@ from .main import main
__author__ = 'Daniel Dunbar'
__email__ = 'daniel@zuster.org'
-__versioninfo__ = (0, 3, 0)
+__versioninfo__ = (0, 4, 0)
__version__ = '.'.join(str(v) for v in __versioninfo__) + 'dev'
__all__ = []
diff --git a/utils/lit/lit/formats/googletest.py b/utils/lit/lit/formats/googletest.py
index b77e184..3d14b729 100644
--- a/utils/lit/lit/formats/googletest.py
+++ b/utils/lit/lit/formats/googletest.py
@@ -66,7 +66,7 @@ class GoogleTest(TestFormat):
# Discover the tests in this executable.
for testname in self.getGTestTests(execpath, litConfig, localConfig):
testPath = path_in_suite + (basename, testname)
- yield lit.Test.Test(testSuite, testPath, localConfig)
+ yield lit.Test.Test(testSuite, testPath, localConfig, file_path=execpath)
def getTestsInDirectory(self, testSuite, path_in_suite,
litConfig, localConfig):
diff --git a/utils/lit/lit/main.py b/utils/lit/lit/main.py
index 6f672a0..c59651a 100755
--- a/utils/lit/lit/main.py
+++ b/utils/lit/lit/main.py
@@ -34,6 +34,10 @@ class TestingProgressDisplay(object):
def update(self, test):
self.completed += 1
+
+ if self.opts.incremental:
+ update_incremental_cache(test)
+
if self.progressBar:
self.progressBar.update(float(self.completed)/self.numTests,
test.getFullName())
@@ -108,6 +112,21 @@ def write_test_results(run, lit_config, testing_time, output_path):
finally:
f.close()
+def update_incremental_cache(test):
+ if not test.result.code.isFailure:
+ return
+ fname = test.getFilePath()
+ os.utime(fname, None)
+
+def sort_by_incremental_cache(run):
+ def sortIndex(test):
+ fname = test.getFilePath()
+ try:
+ return -os.path.getmtime(fname)
+ except:
+ return 0
+ run.tests.sort(key = lambda t: sortIndex(t))
+
def main(builtinParameters = {}):
# Use processes by default on Unix platforms.
isWindows = platform.system() == 'Windows'
@@ -117,6 +136,9 @@ def main(builtinParameters = {}):
from optparse import OptionParser, OptionGroup
parser = OptionParser("usage: %prog [options] {file-or-path}")
+ parser.add_option("", "--version", dest="show_version",
+ help="Show version and exit",
+ action="store_true", default=False)
parser.add_option("-j", "--threads", dest="numThreads", metavar="N",
help="Number of testing threads",
type=int, action="store", default=None)
@@ -179,6 +201,10 @@ def main(builtinParameters = {}):
group.add_option("", "--shuffle", dest="shuffle",
help="Run tests in random order",
action="store_true", default=False)
+ group.add_option("-i", "--incremental", dest="incremental",
+ help="Run modified and failing tests first (updates "
+ "mtimes)",
+ action="store_true", default=False)
group.add_option("", "--filter", dest="filter", metavar="REGEX",
help=("Only run tests with paths matching the given "
"regular expression"),
@@ -205,6 +231,10 @@ def main(builtinParameters = {}):
(opts, args) = parser.parse_args()
+ if opts.show_version:
+ print("lit %s" % (lit.__version__,))
+ return
+
if not args:
parser.error('No inputs specified')
@@ -292,6 +322,8 @@ def main(builtinParameters = {}):
# Then select the order.
if opts.shuffle:
random.shuffle(run.tests)
+ elif opts.incremental:
+ sort_by_incremental_cache(run)
else:
run.tests.sort(key = lambda t: t.getFullName())
diff --git a/utils/lit/utils/check-sdist b/utils/lit/utils/check-sdist
index 6186446..743a971 100755
--- a/utils/lit/utils/check-sdist
+++ b/utils/lit/utils/check-sdist
@@ -12,6 +12,7 @@ find . | \
grep -v '^\./dist' | \
grep -v '^\./utils' | \
grep -v '^\./venv' | \
+ grep -v '^\./notes.txt' | \
grep -v '^\./lit.egg-info' | \
grep -v '^\./lit/ExampleTests' | \
grep -v '/Output' | \