mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
[lit] Lift XFAIL handling to core infrastructure.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188949 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d3bf8a2c0a
commit
f72bc79226
@ -59,6 +59,10 @@ class Test:
|
|||||||
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
|
||||||
|
# A list of conditions under which this test is expected to fail. These
|
||||||
|
# can optionally be provided by test format handlers, and will be
|
||||||
|
# honored when the test result is supplied.
|
||||||
|
self.xfails = []
|
||||||
# The test result, once complete.
|
# The test result, once complete.
|
||||||
self.result = None
|
self.result = None
|
||||||
|
|
||||||
@ -70,6 +74,13 @@ class Test:
|
|||||||
|
|
||||||
self.result = result
|
self.result = result
|
||||||
|
|
||||||
|
# Apply the XFAIL handling to resolve the result exit code.
|
||||||
|
if self.isExpectedToFail():
|
||||||
|
if self.result.code == PASS:
|
||||||
|
self.result.code = XPASS
|
||||||
|
elif self.result.code == FAIL:
|
||||||
|
self.result.code = XFAIL
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
@ -78,3 +89,29 @@ class Test:
|
|||||||
|
|
||||||
def getExecPath(self):
|
def getExecPath(self):
|
||||||
return self.suite.getExecPath(self.path_in_suite)
|
return self.suite.getExecPath(self.path_in_suite)
|
||||||
|
|
||||||
|
def isExpectedToFail(self):
|
||||||
|
"""
|
||||||
|
isExpectedToFail() -> bool
|
||||||
|
|
||||||
|
Check whether this test is expected to fail in the current
|
||||||
|
configuration. This check relies on the test xfails property which by
|
||||||
|
some test formats may not be computed until the test has first been
|
||||||
|
executed.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Check if any of the xfails match an available feature or the target.
|
||||||
|
for item in self.xfails:
|
||||||
|
# If this is the wildcard, it always fails.
|
||||||
|
if item == '*':
|
||||||
|
return True
|
||||||
|
|
||||||
|
# If this is an exact match for one of the features, it fails.
|
||||||
|
if item in self.config.available_features:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# If this is a part of the target triple, it fails.
|
||||||
|
if item in self.suite.config.target_triple:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
@ -298,23 +298,6 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
|
|||||||
return lit.util.executeCommand(command, cwd=cwd,
|
return lit.util.executeCommand(command, cwd=cwd,
|
||||||
env=test.config.environment)
|
env=test.config.environment)
|
||||||
|
|
||||||
def isExpectedFail(test, xfails):
|
|
||||||
# Check if any of the xfails match an available feature or the target.
|
|
||||||
for item in xfails:
|
|
||||||
# If this is the wildcard, it always fails.
|
|
||||||
if item == '*':
|
|
||||||
return True
|
|
||||||
|
|
||||||
# If this is an exact match for one of the features, it fails.
|
|
||||||
if item in test.config.available_features:
|
|
||||||
return True
|
|
||||||
|
|
||||||
# If this is a part of the target triple, it fails.
|
|
||||||
if item in test.suite.config.target_triple:
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def parseIntegratedTestScriptCommands(source_path):
|
def parseIntegratedTestScriptCommands(source_path):
|
||||||
"""
|
"""
|
||||||
parseIntegratedTestScriptCommands(source_path) -> commands
|
parseIntegratedTestScriptCommands(source_path) -> commands
|
||||||
@ -415,7 +398,6 @@ def parseIntegratedTestScript(test, normalize_slashes=False,
|
|||||||
|
|
||||||
# Collect the test lines from the script.
|
# Collect the test lines from the script.
|
||||||
script = []
|
script = []
|
||||||
xfails = []
|
|
||||||
requires = []
|
requires = []
|
||||||
for line_number, command_type, ln in \
|
for line_number, command_type, ln in \
|
||||||
parseIntegratedTestScriptCommands(sourcepath):
|
parseIntegratedTestScriptCommands(sourcepath):
|
||||||
@ -438,7 +420,7 @@ def parseIntegratedTestScript(test, normalize_slashes=False,
|
|||||||
else:
|
else:
|
||||||
script.append(ln)
|
script.append(ln)
|
||||||
elif command_type == 'XFAIL':
|
elif command_type == 'XFAIL':
|
||||||
xfails.extend([s.strip() for s in ln.split(',')])
|
test.xfails.extend([s.strip() for s in ln.split(',')])
|
||||||
elif command_type == 'REQUIRES':
|
elif command_type == 'REQUIRES':
|
||||||
requires.extend([s.strip() for s in ln.split(',')])
|
requires.extend([s.strip() for s in ln.split(',')])
|
||||||
elif command_type == 'END':
|
elif command_type == 'END':
|
||||||
@ -480,8 +462,7 @@ def parseIntegratedTestScript(test, normalize_slashes=False,
|
|||||||
return (Test.UNSUPPORTED,
|
return (Test.UNSUPPORTED,
|
||||||
"Test requires the following features: %s" % msg)
|
"Test requires the following features: %s" % msg)
|
||||||
|
|
||||||
isXFail = isExpectedFail(test, xfails)
|
return script,tmpBase,execdir
|
||||||
return script,isXFail,tmpBase,execdir
|
|
||||||
|
|
||||||
def formatTestOutput(status, out, err, exitCode, script):
|
def formatTestOutput(status, out, err, exitCode, script):
|
||||||
output = """\
|
output = """\
|
||||||
@ -521,7 +502,7 @@ def executeShTest(test, litConfig, useExternalSh,
|
|||||||
if len(res) == 2:
|
if len(res) == 2:
|
||||||
return res
|
return res
|
||||||
|
|
||||||
script, isXFail, tmpBase, execdir = res
|
script, tmpBase, execdir = res
|
||||||
|
|
||||||
if litConfig.noExecute:
|
if litConfig.noExecute:
|
||||||
return (Test.PASS, '')
|
return (Test.PASS, '')
|
||||||
@ -537,20 +518,9 @@ def executeShTest(test, litConfig, useExternalSh,
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
out,err,exitCode = res
|
out,err,exitCode = res
|
||||||
if isXFail:
|
if exitCode == 0:
|
||||||
ok = exitCode != 0
|
status = Test.PASS
|
||||||
if ok:
|
|
||||||
status = Test.XFAIL
|
|
||||||
else:
|
|
||||||
status = Test.XPASS
|
|
||||||
else:
|
else:
|
||||||
ok = exitCode == 0
|
status = Test.FAIL
|
||||||
if ok:
|
|
||||||
status = Test.PASS
|
|
||||||
else:
|
|
||||||
status = Test.FAIL
|
|
||||||
|
|
||||||
if ok:
|
|
||||||
return (status,'')
|
|
||||||
|
|
||||||
return formatTestOutput(status, out, err, exitCode, script)
|
return formatTestOutput(status, out, err, exitCode, script)
|
||||||
|
@ -53,6 +53,11 @@
|
|||||||
# CHECK: XFAIL: shtest-format :: xfail-target.txt
|
# CHECK: XFAIL: shtest-format :: xfail-target.txt
|
||||||
# CHECK: XFAIL: shtest-format :: xfail.txt
|
# CHECK: XFAIL: shtest-format :: xfail.txt
|
||||||
# CHECK: XPASS: shtest-format :: xpass.txt
|
# CHECK: XPASS: shtest-format :: xpass.txt
|
||||||
|
# CHECK-NEXT: *** TEST 'shtest-format :: xpass.txt' FAILED ***
|
||||||
|
# CHECK-NEXT: Script
|
||||||
|
# CHECK-NEXT: --
|
||||||
|
# CHECK-NEXT: true
|
||||||
|
# CHECK-NEXT: --
|
||||||
# CHECK: Testing Time
|
# CHECK: Testing Time
|
||||||
|
|
||||||
# CHECK: Unexpected Passing Tests (1)
|
# CHECK: Unexpected Passing Tests (1)
|
||||||
|
Loading…
Reference in New Issue
Block a user