5 class ResultCode(object):
6 """Test result codes."""
8 # We override __new__ and __getnewargs__ to ensure that pickling still
9 # provides unique ResultCode objects in any particular instance.
11 def __new__(cls, name, isFailure):
12 res = cls._instances.get(name)
14 cls._instances[name] = res = super(ResultCode, cls).__new__(cls)
16 def __getnewargs__(self):
17 return (self.name, self.isFailure)
19 def __init__(self, name, isFailure):
21 self.isFailure = isFailure
24 return '%s%r' % (self.__class__.__name__,
25 (self.name, self.isFailure))
27 PASS = ResultCode('PASS', False)
28 XFAIL = ResultCode('XFAIL', False)
29 FAIL = ResultCode('FAIL', True)
30 XPASS = ResultCode('XPASS', True)
31 UNRESOLVED = ResultCode('UNRESOLVED', True)
32 UNSUPPORTED = ResultCode('UNSUPPORTED', False)
35 """Wrapper for the results of executing an individual test."""
37 def __init__(self, code, output='', elapsed=None):
42 # The wall timing to execute the test, if timing.
43 self.elapsed = elapsed
48 """TestSuite - Information on a group of tests.
50 A test suite groups together a set of logically related tests.
53 def __init__(self, name, source_root, exec_root, config):
55 self.source_root = source_root
56 self.exec_root = exec_root
57 # The test suite configuration.
60 def getSourcePath(self, components):
61 return os.path.join(self.source_root, *components)
63 def getExecPath(self, components):
64 return os.path.join(self.exec_root, *components)
67 """Test - Information on a single test instance."""
69 def __init__(self, suite, path_in_suite, config):
71 self.path_in_suite = path_in_suite
73 # A list of conditions under which this test is expected to fail. These
74 # can optionally be provided by test format handlers, and will be
75 # honored when the test result is supplied.
77 # The test result, once complete.
80 def setResult(self, result):
81 if self.result is not None:
82 raise ArgumentError("test result already set")
83 if not isinstance(result, Result):
84 raise ArgumentError("unexpected result type")
88 # Apply the XFAIL handling to resolve the result exit code.
89 if self.isExpectedToFail():
90 if self.result.code == PASS:
91 self.result.code = XPASS
92 elif self.result.code == FAIL:
93 self.result.code = XFAIL
95 def getFullName(self):
96 return self.suite.config.name + ' :: ' + '/'.join(self.path_in_suite)
98 def getSourcePath(self):
99 return self.suite.getSourcePath(self.path_in_suite)
101 def getExecPath(self):
102 return self.suite.getExecPath(self.path_in_suite)
104 def isExpectedToFail(self):
106 isExpectedToFail() -> bool
108 Check whether this test is expected to fail in the current
109 configuration. This check relies on the test xfails property which by
110 some test formats may not be computed until the test has first been
114 # Check if any of the xfails match an available feature or the target.
115 for item in self.xfails:
116 # If this is the wildcard, it always fails.
120 # If this is an exact match for one of the features, it fails.
121 if item in self.config.available_features:
124 # If this is a part of the target triple, it fails.
125 if item in self.suite.config.target_triple: