Automatically detect and use clang verify in failure tests.
Automatically enable clang verify whenever the '-verify-ignore-unexpected' flag is supported. Failure tests are run using verify if they contain one or more "expected-*" diagnostics tags. Otherwise they are run normally. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@241492 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0c5dd15e09
commit
faaf5ee349
@ -139,7 +139,10 @@ class CXXCompiler(object):
|
||||
return lit.util.capture(cmd).strip()
|
||||
|
||||
def hasCompileFlag(self, flag):
|
||||
flags = [flag]
|
||||
if isinstance(flag, list):
|
||||
flags = list(flag)
|
||||
else:
|
||||
flags = [flag]
|
||||
# Add -Werror to ensure that an unrecognized flag causes a non-zero
|
||||
# exit code. -Werror is supported on all known compiler types.
|
||||
if self.type is not None:
|
||||
|
@ -201,8 +201,10 @@ class Configuration(object):
|
||||
'''If set, run clang with -verify on failing tests.'''
|
||||
self.use_clang_verify = self.get_lit_bool('use_clang_verify')
|
||||
if self.use_clang_verify is None:
|
||||
# TODO: Default this to True when using clang.
|
||||
self.use_clang_verify = False
|
||||
# NOTE: We do not test for the -verify flag directly because
|
||||
# -verify will always exit with non-zero on an empty file.
|
||||
self.use_clang_verify = self.cxx.hasCompileFlag(
|
||||
['-Xclang', '-verify-ignore-unexpected'])
|
||||
self.lit_config.note(
|
||||
"inferred use_clang_verify as: %r" % self.use_clang_verify)
|
||||
|
||||
|
@ -141,13 +141,16 @@ class LibcxxTestFormat(object):
|
||||
|
||||
def _evaluate_fail_test(self, test):
|
||||
source_path = test.getSourcePath()
|
||||
# TODO: Move the checking of USE_VERIFY into
|
||||
# lit.TestRunner.parseIntegratedTestScript by adding support for custom
|
||||
# tags.
|
||||
with open(source_path, 'r') as f:
|
||||
contents = f.read()
|
||||
use_verify = 'USE_VERIFY' in contents and self.use_verify_for_fail
|
||||
extra_flags = ['-Xclang', '-verify'] if use_verify else []
|
||||
verify_tags = ['expected-note', 'expected-remark', 'expected-warning',
|
||||
'expected-error', 'expected-no-diagnostics']
|
||||
use_verify = self.use_verify_for_fail and \
|
||||
any([tag in contents for tag in verify_tags])
|
||||
extra_flags = []
|
||||
if use_verify:
|
||||
extra_flags += ['-Xclang', '-verify',
|
||||
'-Xclang', '-verify-ignore-unexpected=note']
|
||||
cmd, out, err, rc = self.cxx.compile(source_path, out=os.devnull,
|
||||
flags=extra_flags)
|
||||
expected_rc = 0 if use_verify else 1
|
||||
@ -155,5 +158,6 @@ class LibcxxTestFormat(object):
|
||||
return lit.Test.PASS, ''
|
||||
else:
|
||||
report = libcxx.util.makeReport(cmd, out, err, rc)
|
||||
return (lit.Test.FAIL,
|
||||
report + 'Expected compilation to fail!\n')
|
||||
report_msg = ('Expected compilation to fail!' if use_verify else
|
||||
'Expected compilation using verify to pass!')
|
||||
return lit.Test.FAIL, report + report_msg + '\n'
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
// default unique_ptr ctor should require default Deleter ctor
|
||||
|
||||
// USE_VERIFY
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user