[PATCH] D121422: [clang-tools-extra] Reuse llvm_config.use_clang() to set up test environment

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 15 14:15:42 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b69eb4a7d1d: [clang-tools-extra] Reuse llvm_config.use_clang() to set up test environment (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D121422?vs=414514&id=415581#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121422/new/

https://reviews.llvm.org/D121422

Files:
  clang-tools-extra/test/lit.cfg.py
  clang-tools-extra/test/lit.site.cfg.py.in


Index: clang-tools-extra/test/lit.site.cfg.py.in
===================================================================
--- clang-tools-extra/test/lit.site.cfg.py.in
+++ clang-tools-extra/test/lit.site.cfg.py.in
@@ -5,9 +5,11 @@
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@"
-config.clang_libs_dir = "@SHLIBDIR@"
+config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.llvm_shlib_dir = "@SHLIBDIR@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
+config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
 config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
 # Support substitution of the tools and libs dirs with user parameters. This is
Index: clang-tools-extra/test/lit.cfg.py
===================================================================
--- clang-tools-extra/test/lit.cfg.py
+++ clang-tools-extra/test/lit.cfg.py
@@ -1,13 +1,9 @@
 # -*- Python -*-
 
 import os
-import platform
-import re
 import shlex
-import subprocess
 
 import lit.formats
-import lit.util
 
 from lit.llvm import llvm_config
 
@@ -33,43 +29,8 @@
 # test_exec_root: The root path where tests should be run.
 config.test_exec_root = os.path.join(config.clang_tools_binary_dir, 'test')
 
-# Clear some environment variables that might affect Clang.
-#
-# This first set of vars are read by Clang, but shouldn't affect tests
-# that aren't specifically looking for these features, or are required
-# simply to run the tests at all.
-#
-# FIXME: Should we have a tool that enforces this?
-
-# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
-#                  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
-#                  'IOS_SIMULATOR_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')
-for name in possibly_dangerous_env_vars:
-  if name in config.environment:
-    del config.environment[name]
-
-# Tweak the PATH to include the tools dir and the scripts dir.
-path = os.path.pathsep.join((
-        config.clang_tools_dir, config.llvm_tools_dir, config.environment['PATH']))
-config.environment['PATH'] = path
-
-path = os.path.pathsep.join((config.clang_libs_dir, config.llvm_libs_dir,
-                              config.environment.get('LD_LIBRARY_PATH','')))
-config.environment['LD_LIBRARY_PATH'] = path
+# Tools need the same environment setup as clang (we don't need clang itself).
+llvm_config.use_clang(required = False)
 
 if config.clang_tidy_staticanalyzer:
     config.available_features.add('static-analyzer')
@@ -91,9 +52,6 @@
     ('%run_clang_tidy',
      '%s %s' % (python_exec, run_clang_tidy)) )
 
-config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
-config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
-
 # Plugins (loadable modules)
 if config.has_plugins and config.llvm_plugin_ext:
     config.available_features.add('plugins')


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121422.415581.patch
Type: text/x-patch
Size: 3926 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220315/8d96c96c/attachment.bin>


More information about the cfe-commits mailing list