[libcxx] r288743 - Add support for writing -verify shell tests

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 5 17:02:15 PST 2016


Author: ericwf
Date: Mon Dec  5 19:02:15 2016
New Revision: 288743

URL: http://llvm.org/viewvc/llvm-project?rev=288743&view=rev
Log:
Add support for writing -verify shell tests

Modified:
    libcxx/trunk/test/libcxx/compiler.py
    libcxx/trunk/test/libcxx/test/config.py
    libcxx/trunk/test/libcxx/test/format.py

Modified: libcxx/trunk/test/libcxx/compiler.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/compiler.py?rev=288743&r1=288742&r2=288743&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/compiler.py (original)
+++ libcxx/trunk/test/libcxx/compiler.py Mon Dec  5 19:02:15 2016
@@ -20,14 +20,21 @@ class CXXCompiler(object):
     CM_Link = 3
 
     def __init__(self, path, flags=None, compile_flags=None, link_flags=None,
-                 warning_flags=None, modules_flags=None, use_modules=False,
+                 warning_flags=None, verify_supported=None,
+                 verify_flags=None, use_verify=False,
+                 modules_flags=None, use_modules=False,
                  use_ccache=False, use_warnings=False, compile_env=None,
                  cxx_type=None, cxx_version=None):
         self.path = path
         self.flags = list(flags or [])
         self.compile_flags = list(compile_flags or [])
-        self.warning_flags = list(warning_flags or [])
         self.link_flags = list(link_flags or [])
+        self.warning_flags = list(warning_flags or [])
+        self.verify_supported = verify_supported
+        self.use_verify = use_verify
+        self.verify_flags = list(verify_flags or [])
+        assert not use_verify or verify_supported
+        assert not use_verify or verify_flags is not None
         self.modules_flags = list(modules_flags or [])
         self.use_modules = use_modules
         assert not use_modules or modules_flags is not None
@@ -46,12 +53,30 @@ class CXXCompiler(object):
         new_cxx = CXXCompiler(
             self.path, flags=self.flags, compile_flags=self.compile_flags,
             link_flags=self.link_flags, warning_flags=self.warning_flags,
+            verify_supported=self.verify_supported,
+            verify_flags=self.verify_flags, use_verify=self.use_verify,
             modules_flags=self.modules_flags, use_modules=self.use_modules,
             use_ccache=self.use_ccache, use_warnings=self.use_warnings,
             compile_env=self.compile_env, cxx_type=self.type,
             cxx_version=self.version)
         return new_cxx
 
+    def isVerifySupported(self):
+        if self.verify_supported is None:
+            self.verify_supported = self.hasCompileFlag(['-Xclang',
+                                        '-verify-ignore-unexpected'])
+            if self.verify_supported:
+                self.verify_flags = [
+                    '-Xclang', '-verify',
+                    '-Xclang', '-verify-ignore-unexpected=note',
+                    '-ferror-limit=1024'
+                ]
+        return self.verify_supported
+
+    def useVerify(self, value=True):
+        self.use_verify = value
+        assert not self.use_verify or self.verify_flags is not None
+
     def useModules(self, value=True):
         self.use_modules = value
         assert not self.use_modules or self.modules_flags is not None
@@ -108,6 +133,9 @@ class CXXCompiler(object):
         elif mode == self.CM_Compile:
             cmd += ['-c']
         cmd += self.flags
+        if self.use_verify:
+            cmd += self.verify_flags
+            assert mode in [self.CM_Default, self.CM_Compile]
         if self.use_modules:
             cmd += self.modules_flags
         if mode != self.CM_Link:

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=288743&r1=288742&r2=288743&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Mon Dec  5 19:02:15 2016
@@ -251,8 +251,9 @@ class Configuration(object):
         if self.use_clang_verify is None:
             # 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.use_clang_verify = self.cxx.isVerifySupported()
+            if self.use_clang_verify:
+                self.config.available_features.add('verify-support')
             self.lit_config.note(
                 "inferred use_clang_verify as: %r" % self.use_clang_verify)
 
@@ -771,21 +772,25 @@ class Configuration(object):
         sub.append(('%compile_flags', compile_flags_str))
         sub.append(('%link_flags', link_flags_str))
         sub.append(('%all_flags', all_flags))
-
+        if self.cxx.isVerifySupported():
+            verify_str = ' ' + ' '.join(self.cxx.verify_flags) + ' '
+            sub.append(('%verify', verify_str))
         # Add compile and link shortcuts
         compile_str = (self.cxx.path + ' -o %t.o %s -c ' + flags_str
-                       + compile_flags_str)
-        link_str = (self.cxx.path + ' -o %t.exe %t.o ' + flags_str
+                       + ' ' + compile_flags_str)
+        link_str = (self.cxx.path + ' -o %t.exe %t.o ' + flags_str + ' '
                     + link_flags_str)
         assert type(link_str) is str
         build_str = self.cxx.path + ' -o %t.exe %s ' + all_flags
-        sub.append(('%compile', compile_str))
-        sub.append(('%link', link_str))
         if self.cxx.use_modules:
+            sub.append(('%compile_module', compile_str))
             sub.append(('%build_module', build_str))
         elif self.cxx.modules_flags is not None:
             modules_str = ' '.join(self.cxx.modules_flags) + ' '
+            sub.append(('%compile_module', compile_str + ' ' + modules_str))
             sub.append(('%build_module', build_str + ' ' + modules_str))
+        sub.append(('%compile', compile_str))
+        sub.append(('%link', link_str))
         sub.append(('%build', build_str))
         # Configure exec prefix substitutions.
         exec_env_str = 'env ' if len(self.env) != 0 else ''
@@ -800,8 +805,8 @@ class Configuration(object):
         sub.append(('%run', exec_str + ' %t.exe'))
         # Configure not program substitutions
         not_py = os.path.join(self.libcxx_src_root, 'utils', 'not', 'not.py')
-        not_str = '%s %s' % (sys.executable, not_py)
-        sub.append(('not', not_str))
+        not_str = '%s %s ' % (sys.executable, not_py)
+        sub.append(('not ', not_str))
 
     def configure_triple(self):
         # Get or infer the target triple.

Modified: libcxx/trunk/test/libcxx/test/format.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/format.py?rev=288743&r1=288742&r2=288743&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/test/format.py (original)
+++ libcxx/trunk/test/libcxx/test/format.py Mon Dec  5 19:02:15 2016
@@ -227,9 +227,7 @@ class LibcxxTestFormat(object):
         if test_cxx.type != 'gcc':
             test_cxx.flags += ['-fsyntax-only']
         if use_verify:
-            test_cxx.flags += ['-Xclang', '-verify',
-                               '-Xclang', '-verify-ignore-unexpected=note',
-                               '-ferror-limit=1024']
+            test_cxx.useVerify()
         cmd, out, err, rc = test_cxx.compile(source_path, out=os.devnull)
         expected_rc = 0 if use_verify else 1
         if rc == expected_rc:




More information about the cfe-commits mailing list