[llvm] 81d4e9c - [lit] rewrap a few lines to 80 columns

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 12 08:55:07 PST 2021


Author: Nico Weber
Date: 2021-03-12T11:55:00-05:00
New Revision: 81d4e9c146fceabd481a7c682703dc2fce8e1300

URL: https://github.com/llvm/llvm-project/commit/81d4e9c146fceabd481a7c682703dc2fce8e1300
DIFF: https://github.com/llvm/llvm-project/commit/81d4e9c146fceabd481a7c682703dc2fce8e1300.diff

LOG: [lit] rewrap a few lines to 80 columns

No behavior change.

Added: 
    

Modified: 
    llvm/utils/lit/lit/llvm/config.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index 878ff9a6f0fa..febd62fd7d21 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -26,7 +26,8 @@ def __init__(self, lit_config, config):
             # Seek necessary tools in directories and set to $PATH.
             path = None
             lit_tools_dir = getattr(config, 'lit_tools_dir', None)
-            required_tools = ['cmp.exe', 'grep.exe', 'sed.exe', '
diff .exe', 'echo.exe']
+            required_tools = [
+                'cmp.exe', 'grep.exe', 'sed.exe', '
diff .exe', 'echo.exe']
             path = self.lit_config.getToolsPath(lit_tools_dir,
                                                 config.environment['PATH'],
                                                 required_tools)
@@ -34,8 +35,10 @@ def __init__(self, lit_config, config):
                 path = self._find_git_windows_unix_tools(required_tools)
             if path is not None:
                 self.with_environment('PATH', path, append_path=True)
-            # Many tools behave strangely if these environment variables aren't set.
-            self.with_system_environment(['SystemDrive', 'SystemRoot', 'TEMP', 'TMP'])
+            # Many tools behave strangely if these environment variables aren't
+            # set.
+            self.with_system_environment(
+                ['SystemDrive', 'SystemRoot', 'TEMP', 'TMP'])
             self.use_lit_shell = True
 
             global lit_path_displayed
@@ -43,8 +46,9 @@ def __init__(self, lit_config, config):
                 self.lit_config.note("using lit tools: {}".format(path))
                 lit_path_displayed = True
 
-        # Choose between lit's internal shell pipeline runner and a real shell.  If
-        # LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
+        # Choose between lit's internal shell pipeline runner and a real shell.
+        # If LIT_USE_INTERNAL_SHELL is in the environment, we use that as an
+        # override.
         lit_shell_env = os.environ.get('LIT_USE_INTERNAL_SHELL')
         if lit_shell_env:
             self.use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
@@ -103,7 +107,8 @@ def __init__(self, lit_config, config):
             if re.match(r'^x86_64.*-apple', target_triple):
                 features.add('x86_64-apple')
                 host_cxx = getattr(config, 'host_cxx', None)
-                if 'address' in sanitizers and self.get_clang_has_lsan(host_cxx, target_triple):
+                if ('address' in sanitizers and
+                        self.get_clang_has_lsan(host_cxx, target_triple)):
                     self.with_environment(
                         'ASAN_OPTIONS', 'detect_leaks=1', append_path=True)
             if re.match(r'^x86_64.*-linux', target_triple):
@@ -121,8 +126,8 @@ def __init__(self, lit_config, config):
         if lit.util.pythonize_bool(use_gmalloc):
             # Allow use of an explicit path for gmalloc library.
             # Will default to '/usr/lib/libgmalloc.dylib' if not set.
-            gmalloc_path_str = lit_config.params.get('gmalloc_path',
-                                                     '/usr/lib/libgmalloc.dylib')
+            gmalloc_path_str = lit_config.params.get(
+                'gmalloc_path', '/usr/lib/libgmalloc.dylib')
             if gmalloc_path_str is not None:
                 self.with_environment(
                     'DYLD_INSERT_LIBRARIES', gmalloc_path_str)
@@ -146,7 +151,8 @@ def _find_git_windows_unix_tools(self, tools_needed):
                     if not install_root:
                         continue
                     candidate_path = os.path.join(install_root, 'usr', 'bin')
-                    if not lit.util.checkToolsPath(candidate_path, tools_needed):
+                    if not lit.util.checkToolsPath(
+                               candidate_path, tools_needed):
                         continue
 
                     # We found it, stop enumerating.
@@ -158,8 +164,8 @@ def _find_git_windows_unix_tools(self, tools_needed):
 
     def with_environment(self, variable, value, append_path=False):
         if append_path:
-            # For paths, we should be able to take a list of them and process all
-            # of them.
+            # For paths, we should be able to take a list of them and process
+            # all of them.
             paths_to_add = value
             if lit.util.is_string(paths_to_add):
                 paths_to_add = [paths_to_add]
@@ -178,8 +184,8 @@ def norm(x):
             # and adding each to the beginning would result in c b a.  So we
             # need to iterate in reverse to end up with the original ordering.
             for p in reversed(paths_to_add):
-                # Move it to the front if it already exists, otherwise insert it at the
-                # beginning.
+                # Move it to the front if it already exists, otherwise insert
+                # it at the beginning.
                 p = norm(p)
                 try:
                     paths.remove(p)
@@ -234,16 +240,17 @@ def feature_config(self, features):
                     if re.search(re_pattern, feature_line):
                         self.config.available_features.add(feature)
 
-    # Note that when substituting %clang_cc1 also fill in the include directory of
-    # the builtin headers. Those are part of even a freestanding environment, but
-    # Clang relies on the driver to locate them.
+    # Note that when substituting %clang_cc1 also fill in the include directory
+    # of the builtin headers. Those are part of even a freestanding
+    # environment, but Clang relies on the driver to locate them.
     def get_clang_builtin_include_dir(self, clang):
-        # FIXME: Rather than just getting the version, we should have clang print
-        # out its resource dir here in an easy to scrape form.
+        # FIXME: Rather than just getting the version, we should have clang
+        # print out its resource dir here in an easy to scrape form.
         clang_dir, _ = self.get_process_output(
             [clang, '-print-file-name=include'])
 
         if not clang_dir:
+            print(clang)
             self.lit_config.fatal(
                 "Couldn't find the include dir for Clang ('%s')" % clang)
 
@@ -258,7 +265,8 @@ def get_clang_builtin_include_dir(self, clang):
     def get_clang_has_lsan(self, clang, triple):
         if not clang:
             self.lit_config.warning(
-                'config.host_cxx is unset but test suite is configured to use sanitizers.')
+                'config.host_cxx is unset but test suite is configured '
+                'to use sanitizers.')
             return False
 
         clang_binary = clang.split()[0]
@@ -274,15 +282,16 @@ def get_clang_has_lsan(self, clang, triple):
             return True
 
         if re.match(r'^x86_64.*-apple', triple):
-            version_regex = re.search(r'version ([0-9]+)\.([0-9]+).([0-9]+)', version_string)
+            version_regex = re.search(r'version ([0-9]+)\.([0-9]+).([0-9]+)',
+                                      version_string)
             major_version_number = int(version_regex.group(1))
             minor_version_number = int(version_regex.group(2))
             patch_version_number = int(version_regex.group(3))
-            if ('Apple LLVM' in version_string) or ('Apple clang' in version_string):
+            if ('Apple LLVM' in version_string or
+                'Apple clang' in version_string):
                 # Apple clang doesn't yet support LSan
                 return False
-            else:
-                return major_version_number >= 5
+            return major_version_number >= 5
 
         return False
 
@@ -348,26 +357,37 @@ def add_tool_substitutions(self, tools, search_dirs=None):
 
     def add_err_msg_substitutions(self):
         host_cxx = getattr(self.config, 'host_cxx', '')
-        # On Windows, python's os.strerror() does not emit the same spelling as the C++ std::error_code.
-        # As a workaround, hardcode the Windows error message.
+        # On Windows, python's os.strerror() does not emit the same spelling as
+        # the C++ std::error_code.  As a workaround, hardcode the Windows error
+        # message.
         if (sys.platform == 'win32' and 'MSYS' not in host_cxx):
-            self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
-            self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
-            self.config.substitutions.append(('%errc_EINVAL', '\'invalid argument\''))
-            self.config.substitutions.append(('%errc_EACCES', '\'permission denied\''))
+            self.config.substitutions.append(
+                ('%errc_ENOENT', '\'no such file or directory\''))
+            self.config.substitutions.append(
+                ('%errc_EISDIR', '\'is a directory\''))
+            self.config.substitutions.append(
+                ('%errc_EINVAL', '\'invalid argument\''))
+            self.config.substitutions.append(
+                ('%errc_EACCES', '\'permission denied\''))
         else:
-            self.config.substitutions.append(('%errc_ENOENT', '\'' + os.strerror(errno.ENOENT) + '\''))
-            self.config.substitutions.append(('%errc_EISDIR', '\'' + os.strerror(errno.EISDIR) + '\''))
-            self.config.substitutions.append(('%errc_EINVAL', '\'' + os.strerror(errno.EINVAL) + '\''))
-            self.config.substitutions.append(('%errc_EACCES', '\'' + os.strerror(errno.EACCES) + '\''))
+            self.config.substitutions.append(
+                ('%errc_ENOENT', '\'' + os.strerror(errno.ENOENT) + '\''))
+            self.config.substitutions.append(
+                ('%errc_EISDIR', '\'' + os.strerror(errno.EISDIR) + '\''))
+            self.config.substitutions.append(
+                ('%errc_EINVAL', '\'' + os.strerror(errno.EINVAL) + '\''))
+            self.config.substitutions.append(
+                ('%errc_EACCES', '\'' + os.strerror(errno.EACCES) + '\''))
 
     def use_default_substitutions(self):
         tool_patterns = [
             ToolSubst('FileCheck', unresolved='fatal'),
-            # Handle these specially as they are strings searched for during testing.
-            ToolSubst(r'\| \bcount\b', command=FindTool(
-                'count'), verbatim=True, unresolved='fatal'),
-            ToolSubst(r'\| \bnot\b', command=FindTool('not'), verbatim=True, unresolved='fatal')]
+            # Handle these specially as they are strings searched for during
+            # testing.
+            ToolSubst(r'\| \bcount\b', command=FindTool('count'),
+                verbatim=True, unresolved='fatal'),
+            ToolSubst(r'\| \bnot\b', command=FindTool('not'),
+                verbatim=True, unresolved='fatal')]
 
         self.config.substitutions.append(('%python', '"%s"' % (sys.executable)))
 
@@ -403,7 +423,8 @@ def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
                 self.lit_config.note('using {}: {}'.format(name, tool))
         return tool
 
-    def use_clang(self, additional_tool_dirs=[], additional_flags=[], required=True):
+    def use_clang(self, additional_tool_dirs=[], additional_flags=[],
+                  required=True):
         """Configure the test suite to be able to invoke clang.
 
         Sets up some environment variables important to clang, locates a
@@ -419,19 +440,22 @@ def use_clang(self, additional_tool_dirs=[], additional_flags=[], required=True)
         #
         # FIXME: Should we have a tool that enforces this?
 
-        # safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
-        #                  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
-        #                  'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
-        #                  'VC80COMNTOOLS')
-        possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
-                                       'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
-                                       'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
-                                       'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
-                                       'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
-                                       'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
-                                       'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
-                                       'LIBCLANG_RESOURCE_USAGE',
-                                       'LIBCLANG_CODE_COMPLETION_LOGGING']
+        # safe_env_vars = (
+        #     'TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
+        #     'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
+        #     'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
+        #     'VC80COMNTOOLS')
+        possibly_dangerous_env_vars = [
+            'COMPILER_PATH', 'RC_DEBUG_OPTIONS',
+            'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
+            'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
+            'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
+            'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
+            'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
+            'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
+            'LIBCLANG_RESOURCE_USAGE',
+            'LIBCLANG_CODE_COMPLETION_LOGGING',
+            ]
         # Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
         if platform.system() != 'Windows':
             possibly_dangerous_env_vars.append('INCLUDE')
@@ -439,14 +463,21 @@ def use_clang(self, additional_tool_dirs=[], additional_flags=[], required=True)
         self.clear_environment(possibly_dangerous_env_vars)
 
         # Tweak the PATH to include the tools dir and the scripts dir.
-        # Put Clang first to avoid LLVM from overriding out-of-tree clang builds.
-        exe_dir_props = [self.config.name.lower() + '_tools_dir', 'clang_tools_dir', 'llvm_tools_dir']
+        # Put Clang first to avoid LLVM from overriding out-of-tree clang
+        # builds.
+        exe_dir_props = [self.config.name.lower() + '_tools_dir',
+                         'clang_tools_dir', 'llvm_tools_dir']
         paths = [getattr(self.config, pp) for pp in exe_dir_props
                  if getattr(self.config, pp, None)]
         paths = additional_tool_dirs + paths
         self.with_environment('PATH', paths, append_path=True)
 
-        lib_dir_props = [self.config.name.lower() + '_libs_dir', 'clang_libs_dir', 'llvm_shlib_dir', 'llvm_libs_dir']
+        lib_dir_props = [
+            self.config.name.lower() + '_libs_dir',
+            'clang_libs_dir',
+            'llvm_shlib_dir',
+            'llvm_libs_dir',
+            ]
         paths = [getattr(self.config, pp) for pp in lib_dir_props
                  if getattr(self.config, pp, None)]
 
@@ -464,59 +495,74 @@ def use_clang(self, additional_tool_dirs=[], additional_flags=[], required=True)
             'clang', search_env='CLANG', required=required)
         if self.config.clang:
           self.config.available_features.add('clang')
-          builtin_include_dir = self.get_clang_builtin_include_dir(self.config.clang)
+          builtin_include_dir = self.get_clang_builtin_include_dir(
+              self.config.clang)
           tool_substitutions = [
-              ToolSubst('%clang', command=self.config.clang, extra_args=additional_flags),
-              ToolSubst('%clang_analyze_cc1', command='%clang_cc1', extra_args=['-analyze', '%analyze', '-setup-static-analyzer']+additional_flags),
-              ToolSubst('%clang_cc1', command=self.config.clang, extra_args=['-cc1', '-internal-isystem', builtin_include_dir, '-nostdsysteminc']+additional_flags),
-              ToolSubst('%clang_cpp', command=self.config.clang, extra_args=['--driver-mode=cpp']+additional_flags),
-              ToolSubst('%clang_cl', command=self.config.clang, extra_args=['--driver-mode=cl']+additional_flags),
-              ToolSubst('%clangxx', command=self.config.clang, extra_args=['--driver-mode=g++']+additional_flags),
+              ToolSubst('%clang', command=self.config.clang,
+                        extra_args=additional_flags),
+              ToolSubst('%clang_analyze_cc1', command='%clang_cc1',
+                        extra_args=['-analyze', '%analyze',
+                                    '-setup-static-analyzer']+additional_flags),
+              ToolSubst('%clang_cc1', command=self.config.clang,
+                        extra_args=['-cc1', '-internal-isystem',
+                                    builtin_include_dir, '-nostdsysteminc'] +
+                                   additional_flags),
+              ToolSubst('%clang_cpp', command=self.config.clang,
+                        extra_args=['--driver-mode=cpp']+additional_flags),
+              ToolSubst('%clang_cl', command=self.config.clang,
+                        extra_args=['--driver-mode=cl']+additional_flags),
+              ToolSubst('%clangxx', command=self.config.clang,
+                        extra_args=['--driver-mode=g++']+additional_flags),
               ]
           self.add_tool_substitutions(tool_substitutions)
           self.config.substitutions.append(
               ('%resource_dir', builtin_include_dir))
 
-        self.config.substitutions.append(('%itanium_abi_triple',
-                                          self.make_itanium_abi_triple(self.config.target_triple)))
-        self.config.substitutions.append(('%ms_abi_triple',
-                                          self.make_msabi_triple(self.config.target_triple)))
+        self.config.substitutions.append(
+            ('%itanium_abi_triple',
+             self.make_itanium_abi_triple(self.config.target_triple)))
+        self.config.substitutions.append(
+            ('%ms_abi_triple',
+             self.make_msabi_triple(self.config.target_triple)))
 
-        # The host triple might not be set, at least if we're compiling clang from
-        # an already installed llvm.
-        if self.config.host_triple and self.config.host_triple != '@LLVM_HOST_TRIPLE@':
-            self.config.substitutions.append(('%target_itanium_abi_host_triple',
-                                              '--target=%s' % self.make_itanium_abi_triple(self.config.host_triple)))
+        # The host triple might not be set, at least if we're compiling clang
+        # from an already installed llvm.
+        if (self.config.host_triple and
+                self.config.host_triple != '@LLVM_HOST_TRIPLE@'):
+            self.config.substitutions.append(
+                ('%target_itanium_abi_host_triple',
+                 '--target=' + self.make_itanium_abi_triple(
+                                   self.config.host_triple)))
         else:
             self.config.substitutions.append(
                 ('%target_itanium_abi_host_triple', ''))
 
         # FIXME: Find nicer way to prohibit this.
+        def prefer(this, to):
+            return '''\"*** Do not use '%s' in tests, use '%s'. ***\"''' % (
+                to, this)
         self.config.substitutions.append(
-            (' clang ', """\"*** Do not use 'clang' in tests, use '%clang'. ***\""""))
+            (' clang ', prefer('%clang', 'clang')))
         self.config.substitutions.append(
-            (r' clang\+\+ ', """\"*** Do not use 'clang++' in tests, use '%clangxx'. ***\""""))
+            (r' clang\+\+ ', prefer('%clangxx', 'clang++')))
         self.config.substitutions.append(
-            (' clang-cc ',
-             """\"*** Do not use 'clang-cc' in tests, use '%clang_cc1'. ***\""""))
+            (' clang-cc ', prefer('%clang_cc1', 'clang-cc')))
         self.config.substitutions.append(
-            (' clang-cl ',
-             """\"*** Do not use 'clang-cl' in tests, use '%clang_cl'. ***\""""))
+            (' clang-cl ', prefer('%clang_cl', 'clang-cl')))
         self.config.substitutions.append(
             (' clang -cc1 -analyze ',
-             """\"*** Do not use 'clang -cc1 -analyze' in tests, use '%clang_analyze_cc1'. ***\""""))
+             prefer('%clang_analyze_cc1', 'clang -cc1 -analyze')))
         self.config.substitutions.append(
-            (' clang -cc1 ',
-             """\"*** Do not use 'clang -cc1' in tests, use '%clang_cc1'. ***\""""))
+            (' clang -cc1 ', prefer('%clang_cc1', 'clang -cc1')))
         self.config.substitutions.append(
             (' %clang-cc1 ',
-             """\"*** invalid substitution, use '%clang_cc1'. ***\""""))
+             '''\"*** invalid substitution, use '%clang_cc1'. ***\"'''))
         self.config.substitutions.append(
             (' %clang-cpp ',
-             """\"*** invalid substitution, use '%clang_cpp'. ***\""""))
+             '''\"*** invalid substitution, use '%clang_cpp'. ***\"'''))
         self.config.substitutions.append(
             (' %clang-cl ',
-             """\"*** invalid substitution, use '%clang_cl'. ***\""""))
+             '''\"*** invalid substitution, use '%clang_cl'. ***\"'''))
 
     def use_lld(self, additional_tool_dirs=[], required=True):
         """Configure the test suite to be able to invoke lld.
@@ -528,13 +574,15 @@ def use_lld(self, additional_tool_dirs=[], required=True):
         """
 
         # Tweak the PATH to include the tools dir and the scripts dir.
-        exe_dir_props = [self.config.name.lower() + '_tools_dir', 'lld_tools_dir', 'llvm_tools_dir']
+        exe_dir_props = [self.config.name.lower() + '_tools_dir',
+                         'lld_tools_dir', 'llvm_tools_dir']
         paths = [getattr(self.config, pp) for pp in exe_dir_props
                  if getattr(self.config, pp, None)]
         paths = additional_tool_dirs + paths
         self.with_environment('PATH', paths, append_path=True)
 
-        lib_dir_props = [self.config.name.lower() + '_libs_dir', 'lld_libs_dir', 'llvm_libs_dir']
+        lib_dir_props = [self.config.name.lower() + '_libs_dir',
+                         'lld_libs_dir', 'llvm_libs_dir']
         paths = [getattr(self.config, pp) for pp in lib_dir_props
                  if getattr(self.config, pp, None)]
 


        


More information about the llvm-commits mailing list