[libcxx] r241492 - Automatically detect and use clang verify in failure tests.
Eric Fiselier
eric at efcs.ca
Mon Jul 6 12:56:45 PDT 2015
Author: ericwf
Date: Mon Jul 6 14:56:45 2015
New Revision: 241492
URL: http://llvm.org/viewvc/llvm-project?rev=241492&view=rev
Log:
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.
Modified:
libcxx/trunk/test/libcxx/compiler.py
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/libcxx/test/format.py
libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
Modified: libcxx/trunk/test/libcxx/compiler.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/compiler.py?rev=241492&r1=241491&r2=241492&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/compiler.py (original)
+++ libcxx/trunk/test/libcxx/compiler.py Mon Jul 6 14:56:45 2015
@@ -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:
Modified: libcxx/trunk/test/libcxx/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=241492&r1=241491&r2=241492&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Mon Jul 6 14:56:45 2015
@@ -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)
Modified: libcxx/trunk/test/libcxx/test/format.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/format.py?rev=241492&r1=241491&r2=241492&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/test/format.py (original)
+++ libcxx/trunk/test/libcxx/test/format.py Mon Jul 6 14:56:45 2015
@@ -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'
Modified: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp?rev=241492&r1=241491&r2=241492&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp (original)
+++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp Mon Jul 6 14:56:45 2015
@@ -15,7 +15,6 @@
// default unique_ptr ctor should require default Deleter ctor
-// USE_VERIFY
#include <memory>
More information about the cfe-commits
mailing list