Author: zturner Date: Fri Oct 6 10:54:46 2017 New Revision: 315085 URL: http://llvm.org/viewvc/llvm-project?rev=315085&view=rev Log: [lit] Improve tool substitution in lit.
This addresses two sources of inconsistency in test configuration files. 1. Substitution boundaries. Previously you would specify a substitution, such as 'lli', and then additionally a set of characters that should fail to match before and after the tool. This was used, for example, so that matches that are parts of full paths would not be replaced. But not all tools did this, and those that did would often re-invent the set of characters themselves, leading to inconsistency. Now, every tool substitution defaults to using a sane set of reasonable defaults and you have to explicitly opt out of it. This actually fixed a few latent bugs that were never being surfaced, but only on accident. 2. There was no standard way for the system to decide how to locate a tool. Sometimes you have an explicit path, sometimes we would search for it and build up a path ourselves, and sometimes we would build up a full command line. Furthermore, there was no standardized way to handle missing tools. Do we warn, fail, ignore, etc? All of this is now encapsulated in the ToolSubst class. You either specify an exact command to run, or an instance of FindTool('<tool-name>') and everything else just works. Furthermore, you can specify an action to take if the tool cannot be resolved. Differential Revision: https://reviews.llvm.org/D38565 Modified: cfe/trunk/test/Index/recover-bad-code-rdar_7487294.c cfe/trunk/test/lit.cfg.py Modified: cfe/trunk/test/Index/recover-bad-code-rdar_7487294.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/recover-bad-code-rdar_7487294.c?rev=315085&r1=315084&r2=315085&view=diff ============================================================================== --- cfe/trunk/test/Index/recover-bad-code-rdar_7487294.c (original) +++ cfe/trunk/test/Index/recover-bad-code-rdar_7487294.c Fri Oct 6 10:54:46 2017 @@ -1,4 +1,4 @@ -// RUN: not %clang-cc1 -fsyntax-only %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s // IMPORTANT: This test case intentionally DOES NOT use --disable-free. It // tests that we are properly reclaiming the ASTs and we do not have a double free. Modified: cfe/trunk/test/lit.cfg.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=315085&r1=315084&r2=315085&view=diff ============================================================================== --- cfe/trunk/test/lit.cfg.py (original) +++ cfe/trunk/test/lit.cfg.py Fri Oct 6 10:54:46 2017 @@ -10,7 +10,8 @@ import lit.formats import lit.util from lit.llvm import llvm_config -from lit.llvm import ToolFilter +from lit.llvm.subst import ToolSubst +from lit.llvm.subst import FindTool # Configuration file for the 'lit' test runner. @@ -76,6 +77,8 @@ llvm_config.with_environment('LD_LIBRARY llvm_config.with_system_environment( ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']) +llvm_config.use_default_substitutions() + # Discover the 'clang' and 'clangcc' to use. @@ -120,44 +123,37 @@ if config.clang_examples: config.available_features.add('examples') builtin_include_dir = llvm_config.get_clang_builtin_include_dir(config.clang) -config.substitutions.append(('%clang_analyze_cc1', - '%clang_cc1 -analyze %analyze')) -config.substitutions.append(('%clang_cc1', - '%s -cc1 -internal-isystem %s -nostdsysteminc' - % (config.clang, builtin_include_dir))) -config.substitutions.append(('%clang_cpp', ' ' + config.clang + - ' --driver-mode=cpp ')) -config.substitutions.append(('%clang_cl', ' ' + config.clang + - ' --driver-mode=cl ')) -config.substitutions.append(('%clangxx', ' ' + config.clang + - ' --driver-mode=g++ ')) - -clang_func_map = lit.util.which( - 'clang-func-mapping', config.environment['PATH']) -if clang_func_map: - config.substitutions.append( - ('%clang_func_map', ' ' + clang_func_map + ' ')) - -config.substitutions.append(('%clang', ' ' + config.clang + ' ')) -config.substitutions.append(('%test_debuginfo', - ' ' + config.llvm_src_root + '/utils/test_debuginfo.pl ')) -config.substitutions.append(('%itanium_abi_triple', - llvm_config.make_itanium_abi_triple(config.target_triple))) -config.substitutions.append(('%ms_abi_triple', - llvm_config.make_msabi_triple(config.target_triple))) -config.substitutions.append(('%resource_dir', builtin_include_dir)) -config.substitutions.append(('%python', config.python_executable)) -# The host triple might not be set, at least if we're compiling clang from -# an already installed llvm. -if config.host_triple and config.host_triple != '@LLVM_HOST_TRIPLE@': - config.substitutions.append(('%target_itanium_abi_host_triple', - '--target=%s' % llvm_config.make_itanium_abi_triple(config.host_triple))) -else: - config.substitutions.append(('%target_itanium_abi_host_triple', '')) +tools = [ + # By specifying %clang_cc1 as part of the substitution, this substitution + # relies on repeated substitution, so must come before %clang_cc1. + ToolSubst('%clang_analyze_cc1', command='%clang_cc1', + extra_args=['-analyze', '%analyze']), + ToolSubst('%clang_cc1', command=config.clang, extra_args=[ + '-cc1', '-internal-isystem', builtin_include_dir, '-nostdsysteminc']), + ToolSubst('%clang_cpp', command=config.clang, + extra_args=['--driver-mode=cpp']), + ToolSubst('%clang_cl', command=config.clang, + extra_args=['--driver-mode=cl']), + ToolSubst('%clangxx', command=config.clang, + extra_args=['--driver-mode=g++']), + ToolSubst('%clang_func_map', command=FindTool( + 'clang-func-mapping'), unresolved='ignore'), + ToolSubst('%clang', command=config.clang), + ToolSubst('%test_debuginfo', command=os.path.join( + config.llvm_src_root, 'utils', 'test_debuginfo.pl')), + 'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 'opt'] -config.substitutions.append( - ('%src_include_dir', config.clang_src_dir + '/include')) +if config.clang_examples: + tools.append('clang-interpreter') + +# For each occurrence of a clang tool name, replace it with the full path to +# the build directory holding that tool. We explicitly specify the directories +# to search to ensure that we get the tools just built and not some random +# tools that might happen to be in the user's PATH. +tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir] + +llvm_config.add_tool_substitutions(tools, tool_dirs) # FIXME: Find nicer way to prohibit this. config.substitutions.append( @@ -183,27 +179,22 @@ config.substitutions.append( (' %clang-cl ', """*** invalid substitution, use '%clang_cl'. ***""")) -# For each occurrence of a clang tool name, replace it with the full path to -# the build directory holding that tool. We explicitly specify the directories -# to search to ensure that we get the tools just built and not some random -# tools that might happen to be in the user's PATH. -tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir] - -tool_patterns = [ - 'FileCheck', 'c-index-test', - ToolFilter('clang-check', pre='-.', post='-.'), - ToolFilter('clang-diff', pre='-.', post='-.'), - ToolFilter('clang-format', pre='-.', post='-.'), - # FIXME: Some clang test uses opt? - ToolFilter('opt', pre='-.', post=r'/\-.'), - # Handle these specially as they are strings searched for during testing. - ToolFilter(r'\| \bcount\b', verbatim=True), - ToolFilter(r'\| \bnot\b', verbatim=True)] +config.substitutions.append(('%itanium_abi_triple', + llvm_config.make_itanium_abi_triple(config.target_triple))) +config.substitutions.append(('%ms_abi_triple', + llvm_config.make_msabi_triple(config.target_triple))) +config.substitutions.append(('%resource_dir', builtin_include_dir)) -if config.clang_examples: - tool_patterns.append(ToolFilter('clang-interpreter', '-.', '-.')) +# The host triple might not be set, at least if we're compiling clang from +# an already installed llvm. +if config.host_triple and config.host_triple != '@LLVM_HOST_TRIPLE@': + config.substitutions.append(('%target_itanium_abi_host_triple', + '--target=%s' % llvm_config.make_itanium_abi_triple(config.host_triple))) +else: + config.substitutions.append(('%target_itanium_abi_host_triple', '')) -llvm_config.add_tool_substitutions(tool_patterns, tool_dirs) +config.substitutions.append( + ('%src_include_dir', config.clang_src_dir + '/include')) # Set available features we allow tests to conditionalize on. # @@ -236,8 +227,6 @@ if platform.system() not in ['Darwin', ' config.available_features.add('libgcc') # Case-insensitive file system - - def is_filesystem_case_insensitive(): handle, path = tempfile.mkstemp( prefix='case-test', dir=config.test_exec_root) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits