5 class ResultCode(object):
6 """Test result codes."""
8 def __init__(self, name, isFailure):
10 self.isFailure = isFailure
13 return '%s%r' % (self.__class__.__name__,
14 (self.name, self.isFailure))
16 PASS = ResultCode('PASS', False)
17 XFAIL = ResultCode('XFAIL', False)
18 FAIL = ResultCode('FAIL', True)
19 XPASS = ResultCode('XPASS', True)
20 UNRESOLVED = ResultCode('UNRESOLVED', True)
21 UNSUPPORTED = ResultCode('UNSUPPORTED', False)
24 """Wrapper for the results of executing an individual test."""
26 def __init__(self, code, output='', elapsed=None):
31 # The wall timing to execute the test, if timing.
32 self.elapsed = elapsed
37 """TestSuite - Information on a group of tests.
39 A test suite groups together a set of logically related tests.
42 def __init__(self, name, source_root, exec_root, config):
44 self.source_root = source_root
45 self.exec_root = exec_root
46 # The test suite configuration.
49 def getSourcePath(self, components):
50 return os.path.join(self.source_root, *components)
52 def getExecPath(self, components):
53 return os.path.join(self.exec_root, *components)
56 """Test - Information on a single test instance."""
58 def __init__(self, suite, path_in_suite, config):
60 self.path_in_suite = path_in_suite
62 # A list of conditions under which this test is expected to fail. These
63 # can optionally be provided by test format handlers, and will be
64 # honored when the test result is supplied.
66 # The test result, once complete.
69 def setResult(self, result):
70 if self.result is not None:
71 raise ArgumentError("test result already set")
72 if not isinstance(result, Result):
73 raise ArgumentError("unexpected result type")
77 # Apply the XFAIL handling to resolve the result exit code.
78 if self.isExpectedToFail():
79 if self.result.code == PASS:
80 self.result.code = XPASS
81 elif self.result.code == FAIL:
82 self.result.code = XFAIL
84 def getFullName(self):
85 return self.suite.config.name + ' :: ' + '/'.join(self.path_in_suite)
87 def getSourcePath(self):
88 return self.suite.getSourcePath(self.path_in_suite)
90 def getExecPath(self):
91 return self.suite.getExecPath(self.path_in_suite)
93 def isExpectedToFail(self):
95 isExpectedToFail() -> bool
97 Check whether this test is expected to fail in the current
98 configuration. This check relies on the test xfails property which by
99 some test formats may not be computed until the test has first been
103 # Check if any of the xfails match an available feature or the target.
104 for item in self.xfails:
105 # If this is the wildcard, it always fails.
109 # If this is an exact match for one of the features, it fails.
110 if item in self.config.available_features:
113 # If this is a part of the target triple, it fails.
114 if item in self.suite.config.target_triple: