[llvm] r188947 - [lit] Factor out a separate Test.Result() object.
Daniel Dunbar
daniel at zuster.org
Wed Aug 21 15:26:37 PDT 2013
Author: ddunbar
Date: Wed Aug 21 17:26:37 2013
New Revision: 188947
URL: http://llvm.org/viewvc/llvm-project?rev=188947&view=rev
Log:
[lit] Factor out a separate Test.Result() object.
Modified:
llvm/trunk/utils/lit/lit/Test.py
llvm/trunk/utils/lit/lit/main.py
Modified: llvm/trunk/utils/lit/lit/Test.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/Test.py?rev=188947&r1=188946&r2=188947&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/Test.py (original)
+++ llvm/trunk/utils/lit/lit/Test.py Wed Aug 21 17:26:37 2013
@@ -2,7 +2,9 @@ import os
# Test results.
-class TestResult:
+class ResultCode(object):
+ """Test result codes."""
+
def __init__(self, name, isFailure):
self.name = name
self.isFailure = isFailure
@@ -11,12 +13,23 @@ class TestResult:
return '%s%r' % (self.__class__.__name__,
(self.name, self.isFailure))
-PASS = TestResult('PASS', False)
-XFAIL = TestResult('XFAIL', False)
-FAIL = TestResult('FAIL', True)
-XPASS = TestResult('XPASS', True)
-UNRESOLVED = TestResult('UNRESOLVED', True)
-UNSUPPORTED = TestResult('UNSUPPORTED', False)
+PASS = ResultCode('PASS', False)
+XFAIL = ResultCode('XFAIL', False)
+FAIL = ResultCode('FAIL', True)
+XPASS = ResultCode('XPASS', True)
+UNRESOLVED = ResultCode('UNRESOLVED', True)
+UNSUPPORTED = ResultCode('UNSUPPORTED', False)
+
+class Result(object):
+ """Wrapper for the results of executing an individual test."""
+
+ def __init__(self, code, output, elapsed):
+ # The result code.
+ self.code = code
+ # The test output.
+ self.output = output
+ # The wall timing to execute the test, if timing.
+ self.elapsed = elapsed
# Test classes.
@@ -46,18 +59,12 @@ class Test:
self.suite = suite
self.path_in_suite = path_in_suite
self.config = config
- # The test result code, once complete.
+ # The test result, once complete.
self.result = None
- # Any additional output from the test, once complete.
- self.output = None
- # The wall time to execute this test, if timing and once complete.
- self.elapsed = None
def setResult(self, result, output, elapsed):
assert self.result is None, "Test result already set!"
- self.result = result
- self.output = output
- self.elapsed = elapsed
+ self.result = Result(result, output, elapsed)
def getFullName(self):
return self.suite.config.name + ' :: ' + '/'.join(self.path_in_suite)
Modified: llvm/trunk/utils/lit/lit/main.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/main.py?rev=188947&r1=188946&r2=188947&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/main.py (original)
+++ llvm/trunk/utils/lit/lit/main.py Wed Aug 21 17:26:37 2013
@@ -27,7 +27,7 @@ class TestingProgressDisplay:
def update(self, test):
# Avoid locking overhead in quiet mode
- if self.opts.quiet and not test.result.isFailure:
+ if self.opts.quiet and not test.result.code.isFailure:
self.completed += 1
return
@@ -52,19 +52,19 @@ class TestingProgressDisplay:
self.progressBar.update(float(self.completed)/self.numTests,
test.getFullName())
- if self.opts.succinct and not test.result.isFailure:
+ if self.opts.succinct and not test.result.code.isFailure:
return
if self.progressBar:
self.progressBar.clear()
- print('%s: %s (%d of %d)' % (test.result.name, test.getFullName(),
+ print('%s: %s (%d of %d)' % (test.result.code.name, test.getFullName(),
self.completed, self.numTests))
- if test.result.isFailure and self.opts.showOutput:
+ if test.result.code.isFailure and self.opts.showOutput:
print("%s TEST '%s' FAILED %s" % ('*'*20, test.getFullName(),
'*'*20))
- print(test.output)
+ print(test.result.output)
print("*" * 20)
sys.stdout.flush()
@@ -380,18 +380,18 @@ def main(builtinParameters = {}):
print('Testing Time: %.2fs'%(time.time() - startTime))
# Update results for any tests which weren't run.
- for t in tests:
- if t.result is None:
- t.setResult(lit.Test.UNRESOLVED, '', 0.0)
+ for test in tests:
+ if test.result is None:
+ test.setResult(lit.Test.UNRESOLVED, '', 0.0)
# List test results organized by kind.
hasFailures = False
byCode = {}
- for t in tests:
- if t.result not in byCode:
- byCode[t.result] = []
- byCode[t.result].append(t)
- if t.result.isFailure:
+ for test in tests:
+ if test.result.code not in byCode:
+ byCode[test.result.code] = []
+ byCode[test.result.code].append(test)
+ if test.result.code.isFailure:
hasFailures = True
# Print each test in any of the failing groups.
@@ -403,16 +403,16 @@ def main(builtinParameters = {}):
continue
print('*'*20)
print('%s (%d):' % (title, len(elts)))
- for t in elts:
- print(' %s' % t.getFullName())
+ for test in elts:
+ print(' %s' % test.getFullName())
sys.stdout.write('\n')
if opts.timeTests and tests:
# Order by time.
- test_times = [(t.getFullName(), t.elapsed)
- for t in tests]
+ test_times = [(test.getFullName(), test.result.elapsed)
+ for test in tests]
lit.util.printHistogram(test_times, title='Tests')
-
+
for name,code in (('Expected Passes ', lit.Test.PASS),
('Expected Failures ', lit.Test.XFAIL),
('Unsupported Tests ', lit.Test.UNSUPPORTED),
More information about the llvm-commits
mailing list