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()
|
return lit.util.capture(cmd).strip()
|
||||||
|
|
||||||
def hasCompileFlag(self, flag):
|
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
|
# Add -Werror to ensure that an unrecognized flag causes a non-zero
|
||||||
# exit code. -Werror is supported on all known compiler types.
|
# exit code. -Werror is supported on all known compiler types.
|
||||||
if self.type is not None:
|
if self.type is not None:
|
||||||
|
@ -201,8 +201,10 @@ class Configuration(object):
|
|||||||
'''If set, run clang with -verify on failing tests.'''
|
'''If set, run clang with -verify on failing tests.'''
|
||||||
self.use_clang_verify = self.get_lit_bool('use_clang_verify')
|
self.use_clang_verify = self.get_lit_bool('use_clang_verify')
|
||||||
if self.use_clang_verify is None:
|
if self.use_clang_verify is None:
|
||||||
# TODO: Default this to True when using clang.
|
# NOTE: We do not test for the -verify flag directly because
|
||||||
self.use_clang_verify = False
|
# -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(
|
self.lit_config.note(
|
||||||
"inferred use_clang_verify as: %r" % self.use_clang_verify)
|
"inferred use_clang_verify as: %r" % self.use_clang_verify)
|
||||||
|
|
||||||
|
@ -141,13 +141,16 @@ class LibcxxTestFormat(object):
|
|||||||
|
|
||||||
def _evaluate_fail_test(self, test):
|
def _evaluate_fail_test(self, test):
|
||||||
source_path = test.getSourcePath()
|
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:
|
with open(source_path, 'r') as f:
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
use_verify = 'USE_VERIFY' in contents and self.use_verify_for_fail
|
verify_tags = ['expected-note', 'expected-remark', 'expected-warning',
|
||||||
extra_flags = ['-Xclang', '-verify'] if use_verify else []
|
'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,
|
cmd, out, err, rc = self.cxx.compile(source_path, out=os.devnull,
|
||||||
flags=extra_flags)
|
flags=extra_flags)
|
||||||
expected_rc = 0 if use_verify else 1
|
expected_rc = 0 if use_verify else 1
|
||||||
@ -155,5 +158,6 @@ class LibcxxTestFormat(object):
|
|||||||
return lit.Test.PASS, ''
|
return lit.Test.PASS, ''
|
||||||
else:
|
else:
|
||||||
report = libcxx.util.makeReport(cmd, out, err, rc)
|
report = libcxx.util.makeReport(cmd, out, err, rc)
|
||||||
return (lit.Test.FAIL,
|
report_msg = ('Expected compilation to fail!' if use_verify else
|
||||||
report + 'Expected compilation to fail!\n')
|
'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
|
// default unique_ptr ctor should require default Deleter ctor
|
||||||
|
|
||||||
// USE_VERIFY
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user