Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
utils/lit/lit/Test.py
Show All 28 Lines | |||||
PASS = ResultCode('PASS', False) | PASS = ResultCode('PASS', False) | ||||
FLAKYPASS = ResultCode('FLAKYPASS', False) | FLAKYPASS = ResultCode('FLAKYPASS', False) | ||||
XFAIL = ResultCode('XFAIL', False) | XFAIL = ResultCode('XFAIL', False) | ||||
FAIL = ResultCode('FAIL', True) | FAIL = ResultCode('FAIL', True) | ||||
XPASS = ResultCode('XPASS', True) | XPASS = ResultCode('XPASS', True) | ||||
UNRESOLVED = ResultCode('UNRESOLVED', True) | UNRESOLVED = ResultCode('UNRESOLVED', True) | ||||
UNSUPPORTED = ResultCode('UNSUPPORTED', False) | UNSUPPORTED = ResultCode('UNSUPPORTED', False) | ||||
TIMEOUT = ResultCode('TIMEOUT', True) | TIMEOUT = ResultCode('TIMEOUT', True) | ||||
UNXFAIL = ResultCode('UNXFAIL', False) | |||||
# Test metric values. | # Test metric values. | ||||
class MetricValue(object): | class MetricValue(object): | ||||
def format(self): | def format(self): | ||||
""" | """ | ||||
format() -> str | format() -> str | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | class Test: | ||||
def __init__(self, suite, path_in_suite, config, file_path = None): | def __init__(self, suite, path_in_suite, config, file_path = None): | ||||
self.suite = suite | self.suite = suite | ||||
self.path_in_suite = path_in_suite | self.path_in_suite = path_in_suite | ||||
self.config = config | self.config = config | ||||
self.file_path = file_path | self.file_path = file_path | ||||
# A list of conditions under which this test is expected to fail. These | # A list of conditions under which this test is expected to fail. These | ||||
# can optionally be provided by test format handlers, and will be | # can optionally be provided by test format handlers, and will be | ||||
# honored when the test result is supplied. | # honored when the test result is supplied. | ||||
self.xfails = [] | self.xfails = {} | ||||
# The test result, once complete. | # The test result, once complete. | ||||
self.result = None | self.result = None | ||||
def setResult(self, result): | def setResult(self, result): | ||||
if self.result is not None: | if self.result is not None: | ||||
raise ArgumentError("test result already set") | raise ArgumentError("test result already set") | ||||
if not isinstance(result, Result): | if not isinstance(result, Result): | ||||
raise ArgumentError("unexpected result type") | raise ArgumentError("unexpected result type") | ||||
self.result = result | self.result = result | ||||
# Apply the XFAIL handling to resolve the result exit code. | # Apply the XFAIL handling to resolve the result exit code. | ||||
if self.isExpectedToFail(): | if self.isExpectedToFail(): | ||||
if self.result.code == PASS: | if self.result.code == PASS: | ||||
self.result.code = XPASS | self.result.code = XPASS | ||||
elif self.result.code == FAIL: | elif self.result.code == FAIL: | ||||
self.result.code = XFAIL | self.result.code = XFAIL | ||||
elif self.result.code == UNXFAIL: | |||||
self.result.code = FAIL | |||||
def getFullName(self): | def getFullName(self): | ||||
return self.suite.config.name + ' :: ' + '/'.join(self.path_in_suite) | return self.suite.config.name + ' :: ' + '/'.join(self.path_in_suite) | ||||
def getFilePath(self): | def getFilePath(self): | ||||
if self.file_path: | if self.file_path: | ||||
return self.file_path | return self.file_path | ||||
return self.getSourcePath() | return self.getSourcePath() | ||||
Show All 10 Lines | def isExpectedToFail(self): | ||||
Check whether this test is expected to fail in the current | Check whether this test is expected to fail in the current | ||||
configuration. This check relies on the test xfails property which by | configuration. This check relies on the test xfails property which by | ||||
some test formats may not be computed until the test has first been | some test formats may not be computed until the test has first been | ||||
executed. | executed. | ||||
""" | """ | ||||
# Check if any of the xfails match an available feature or the target. | # Check if any of the xfails match an available feature or the target. | ||||
for item in self.xfails: | for feature, pr in self.xfails.iteritems(): | ||||
# If this is the wildcard, it always fails. | # If this is the wildcard, it always fails. | ||||
if item == '*': | if feature == '*': | ||||
return True | return True | ||||
# If this is an exact match for one of the features, it fails. | # If this is an exact match for one of the features, it fails. | ||||
if item in self.config.available_features: | if feature in self.config.available_features: | ||||
return True | return True | ||||
# If this is a part of the target triple, it fails. | # If this is a part of the target triple, it fails. | ||||
if item and item in self.suite.config.target_triple: | if feature and feature in self.suite.config.target_triple: | ||||
return True | return True | ||||
return False | return False | ||||
def isEarlyTest(self): | def isEarlyTest(self): | ||||
""" | """ | ||||
isEarlyTest() -> bool | isEarlyTest() -> bool | ||||
Show All 26 Lines |