llvm.org GIT mirror llvm / f72bc79
[lit] Lift XFAIL handling to core infrastructure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188949 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 6 years ago
3 changed file(s) with 48 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
5858 self.suite = suite
5959 self.path_in_suite = path_in_suite
6060 self.config = config
61 # A list of conditions under which this test is expected to fail. These
62 # can optionally be provided by test format handlers, and will be
63 # honored when the test result is supplied.
64 self.xfails = []
6165 # The test result, once complete.
6266 self.result = None
6367
6973
7074 self.result = result
7175
76 # Apply the XFAIL handling to resolve the result exit code.
77 if self.isExpectedToFail():
78 if self.result.code == PASS:
79 self.result.code = XPASS
80 elif self.result.code == FAIL:
81 self.result.code = XFAIL
82
7283 def getFullName(self):
7384 return self.suite.config.name + ' :: ' + '/'.join(self.path_in_suite)
7485
7788
7889 def getExecPath(self):
7990 return self.suite.getExecPath(self.path_in_suite)
91
92 def isExpectedToFail(self):
93 """
94 isExpectedToFail() -> bool
95
96 Check whether this test is expected to fail in the current
97 configuration. This check relies on the test xfails property which by
98 some test formats may not be computed until the test has first been
99 executed.
100 """
101
102 # Check if any of the xfails match an available feature or the target.
103 for item in self.xfails:
104 # If this is the wildcard, it always fails.
105 if item == '*':
106 return True
107
108 # If this is an exact match for one of the features, it fails.
109 if item in self.config.available_features:
110 return True
111
112 # If this is a part of the target triple, it fails.
113 if item in self.suite.config.target_triple:
114 return True
115
116 return False
297297 return lit.util.executeCommand(command, cwd=cwd,
298298 env=test.config.environment)
299299
300 def isExpectedFail(test, xfails):
301 # Check if any of the xfails match an available feature or the target.
302 for item in xfails:
303 # If this is the wildcard, it always fails.
304 if item == '*':
305 return True
306
307 # If this is an exact match for one of the features, it fails.
308 if item in test.config.available_features:
309 return True
310
311 # If this is a part of the target triple, it fails.
312 if item in test.suite.config.target_triple:
313 return True
314
315 return False
316
317300 def parseIntegratedTestScriptCommands(source_path):
318301 """
319302 parseIntegratedTestScriptCommands(source_path) -> commands
414397
415398 # Collect the test lines from the script.
416399 script = []
417 xfails = []
418400 requires = []
419401 for line_number, command_type, ln in \
420402 parseIntegratedTestScriptCommands(sourcepath):
437419 else:
438420 script.append(ln)
439421 elif command_type == 'XFAIL':
440 xfails.extend([s.strip() for s in ln.split(',')])
422 test.xfails.extend([s.strip() for s in ln.split(',')])
441423 elif command_type == 'REQUIRES':
442424 requires.extend([s.strip() for s in ln.split(',')])
443425 elif command_type == 'END':
479461 return (Test.UNSUPPORTED,
480462 "Test requires the following features: %s" % msg)
481463
482 isXFail = isExpectedFail(test, xfails)
483 return script,isXFail,tmpBase,execdir
464 return script,tmpBase,execdir
484465
485466 def formatTestOutput(status, out, err, exitCode, script):
486467 output = """\
520501 if len(res) == 2:
521502 return res
522503
523 script, isXFail, tmpBase, execdir = res
504 script, tmpBase, execdir = res
524505
525506 if litConfig.noExecute:
526507 return (Test.PASS, '')
536517 return res
537518
538519 out,err,exitCode = res
539 if isXFail:
540 ok = exitCode != 0
541 if ok:
542 status = Test.XFAIL
543 else:
544 status = Test.XPASS
520 if exitCode == 0:
521 status = Test.PASS
545522 else:
546 ok = exitCode == 0
547 if ok:
548 status = Test.PASS
549 else:
550 status = Test.FAIL
551
552 if ok:
553 return (status,'')
523 status = Test.FAIL
554524
555525 return formatTestOutput(status, out, err, exitCode, script)
5252 # CHECK: XFAIL: shtest-format :: xfail-target.txt
5353 # CHECK: XFAIL: shtest-format :: xfail.txt
5454 # CHECK: XPASS: shtest-format :: xpass.txt
55 # CHECK-NEXT: *** TEST 'shtest-format :: xpass.txt' FAILED ***
56 # CHECK-NEXT: Script
57 # CHECK-NEXT: --
58 # CHECK-NEXT: true
59 # CHECK-NEXT: --
5560 # CHECK: Testing Time
5661
5762 # CHECK: Unexpected Passing Tests (1)