See lit.pod for more information.
"""
+from __future__ import absolute_import
import math, os, platform, random, re, sys, time, threading, traceback
-import ProgressBar
-import TestRunner
-import Util
-
-import LitConfig
-import Test
+import lit.ProgressBar
+import lit.LitConfig
+import lit.Test
+import lit.Util
import lit.discovery
if self.canceled:
self.lock.release()
return None
-
- try:
- item = self.iter.next()
- except StopIteration:
+ for item in self.iter:
+ break
+ else:
item = None
self.lock.release()
return item
except:
if self.litConfig.debug:
raise
- result = Test.UNRESOLVED
+ result = lit.Test.UNRESOLVED
output = 'Exception during script execution:\n'
output += traceback.format_exc()
output += '\n'
group.add_option("", "--time-tests", dest="timeTests",
help="Track elapsed wall time for each test",
action="store_true", default=False)
+ group.add_option("", "--no-execute", dest="noExecute",
+ help="Don't execute any tests (assume PASS)",
+ action="store_true", default=False)
parser.add_option_group(group)
group = OptionGroup(parser, "Test Selection")
# I haven't seen this bug occur with 2.5.2 and later, so only enable multiple
# threads by default there.
if sys.hexversion >= 0x2050200:
- opts.numThreads = Util.detectCPUs()
+ opts.numThreads = lit.Util.detectCPUs()
else:
opts.numThreads = 1
userParams[name] = val
# Create the global config object.
- litConfig = LitConfig.LitConfig(progname = os.path.basename(sys.argv[0]),
- path = opts.path,
- quiet = opts.quiet,
- useValgrind = opts.useValgrind,
- valgrindLeakCheck = opts.valgrindLeakCheck,
- valgrindArgs = opts.valgrindArgs,
- debug = opts.debug,
- isWindows = (platform.system()=='Windows'),
- params = userParams,
- config_prefix = opts.configPrefix)
+ litConfig = lit.LitConfig.LitConfig(
+ progname = os.path.basename(sys.argv[0]),
+ path = opts.path,
+ quiet = opts.quiet,
+ useValgrind = opts.useValgrind,
+ valgrindLeakCheck = opts.valgrindLeakCheck,
+ valgrindArgs = opts.valgrindArgs,
+ noExecute = opts.noExecute,
+ debug = opts.debug,
+ isWindows = (platform.system()=='Windows'),
+ params = userParams,
+ config_prefix = opts.configPrefix)
tests = lit.discovery.find_tests_for_inputs(litConfig, inputs)
if t.suite not in suitesAndTests:
suitesAndTests[t.suite] = []
suitesAndTests[t.suite].append(t)
- suitesAndTests = suitesAndTests.items()
+ suitesAndTests = list(suitesAndTests.items())
suitesAndTests.sort(key = lambda item: item[0].name)
# Show the suites, if requested.
if not opts.quiet:
if opts.succinct and opts.useProgressBar:
try:
- tc = ProgressBar.TerminalController()
- progressBar = ProgressBar.ProgressBar(tc, header)
+ tc = lit.ProgressBar.TerminalController()
+ progressBar = lit.ProgressBar.ProgressBar(tc, header)
except ValueError:
print(header)
- progressBar = ProgressBar.SimpleProgressBar('Testing: ')
+ progressBar = lit.ProgressBar.SimpleProgressBar('Testing: ')
else:
print(header)
# Update results for any tests which weren't run.
for t in tests:
if t.result is None:
- t.setResult(Test.UNRESOLVED, '', 0.0)
+ t.setResult(lit.Test.UNRESOLVED, '', 0.0)
# List test results organized by kind.
hasFailures = False
hasFailures = True
# FIXME: Show unresolved and (optionally) unsupported tests.
- for title,code in (('Unexpected Passing Tests', Test.XPASS),
- ('Failing Tests', Test.FAIL)):
+ for title,code in (('Unexpected Passing Tests', lit.Test.XPASS),
+ ('Failing Tests', lit.Test.FAIL)):
elts = byCode.get(code)
if not elts:
continue
byTime = list(times.items())
byTime.sort(key = lambda item: item[1])
if byTime:
- Util.printHistogram(byTime, title='Tests')
-
- for name,code in (('Expected Passes ', Test.PASS),
- ('Expected Failures ', Test.XFAIL),
- ('Unsupported Tests ', Test.UNSUPPORTED),
- ('Unresolved Tests ', Test.UNRESOLVED),
- ('Unexpected Passes ', Test.XPASS),
- ('Unexpected Failures', Test.FAIL),):
+ lit.Util.printHistogram(byTime, title='Tests')
+
+ for name,code in (('Expected Passes ', lit.Test.PASS),
+ ('Expected Failures ', lit.Test.XFAIL),
+ ('Unsupported Tests ', lit.Test.UNSUPPORTED),
+ ('Unresolved Tests ', lit.Test.UNRESOLVED),
+ ('Unexpected Passes ', lit.Test.XPASS),
+ ('Unexpected Failures', lit.Test.FAIL),):
if opts.quiet and not code.isFailure:
continue
N = len(byCode.get(code,[]))