blob: 1c16cc73c7446f9dbf75d594695a14ef42514dcb [file] [log] [blame]
Chandler Carruthc5062dc2012-08-07 07:09:141# -*- Python -*-
2
3import os
4import platform
5import re
Sam McCall7f0df312022-03-10 22:57:056import shlex
Chandler Carruthc5062dc2012-08-07 07:09:147import subprocess
8
Daniel Dunbar4d0a3ef2013-08-09 18:49:229import lit.formats
10import lit.util
Chandler Carruthc5062dc2012-08-07 07:09:1411
Sam McCall69924cc2022-03-10 22:09:4612from lit.llvm import llvm_config
13
Chandler Carruthc5062dc2012-08-07 07:09:1414# Configuration file for the 'lit' test runner.
15
Chandler Carruth074a3562013-03-07 10:09:4716# name: The name of this test suite.
17config.name = 'Clang Tools'
18
Chandler Carruthc5062dc2012-08-07 07:09:1419# testFormat: The test format to use to interpret tests.
Sam McCall69924cc2022-03-10 22:09:4620config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
Chandler Carruthc5062dc2012-08-07 07:09:1421
22# suffixes: A list of file extensions to treat as test files.
Alexander Kornienkob816ba02016-01-08 16:37:1123config.suffixes = ['.c', '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
Benjamin Kramer03016b82016-05-31 12:12:1924 '.modularize', '.module-map-checker', '.test']
Chandler Carruthc5062dc2012-08-07 07:09:1425
Edwin Vane9f7a1c12013-08-22 19:44:0726# Test-time dependencies located in directories called 'Inputs' are excluded
27# from test suites; there won't be any lit tests within them.
28config.excludes = ['Inputs']
29
Chandler Carruth074a3562013-03-07 10:09:4730# test_source_root: The root path where tests are located.
31config.test_source_root = os.path.dirname(__file__)
32
33# test_exec_root: The root path where tests should be run.
Zachary Turnerce92db12017-09-15 22:10:4634config.test_exec_root = os.path.join(config.clang_tools_binary_dir, 'test')
Chandler Carruth074a3562013-03-07 10:09:4735
Chandler Carruthc5062dc2012-08-07 07:09:1436# Clear some environment variables that might affect Clang.
37#
38# This first set of vars are read by Clang, but shouldn't affect tests
39# that aren't specifically looking for these features, or are required
40# simply to run the tests at all.
41#
42# FIXME: Should we have a tool that enforces this?
43
44# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
45# 'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
46# 'IOS_SIMULATOR_DEPLOYMENT_TARGET',
47# 'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
48# 'VC80COMNTOOLS')
49possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
50 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
51 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
52 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
53 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
54 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
55 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
56 'LIBCLANG_RESOURCE_USAGE',
57 'LIBCLANG_CODE_COMPLETION_LOGGING']
58# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
59if platform.system() != 'Windows':
60 possibly_dangerous_env_vars.append('INCLUDE')
61for name in possibly_dangerous_env_vars:
62 if name in config.environment:
63 del config.environment[name]
64
65# Tweak the PATH to include the tools dir and the scripts dir.
Zachary Turnerce92db12017-09-15 22:10:4666path = os.path.pathsep.join((
67 config.clang_tools_dir, config.llvm_tools_dir, config.environment['PATH']))
68config.environment['PATH'] = path
Chandler Carruthc5062dc2012-08-07 07:09:1469
Zachary Turnerce92db12017-09-15 22:10:4670path = os.path.pathsep.join((config.clang_libs_dir, config.llvm_libs_dir,
71 config.environment.get('LD_LIBRARY_PATH','')))
72config.environment['LD_LIBRARY_PATH'] = path
David Blaikied7086fb2012-09-04 22:23:3773
Nico Weber33c9dbb2020-09-03 23:37:2974if config.clang_tidy_staticanalyzer:
Michal Gornya81de442017-08-29 05:58:0875 config.available_features.add('static-analyzer')
Stephen Kellya3c42062018-10-01 20:24:2276
Sam McCall7f0df312022-03-10 22:57:0577python_exec = shlex.quote(config.python_executable)
Stephen Kellya3c42062018-10-01 20:24:2278check_clang_tidy = os.path.join(
79 config.test_source_root, "clang-tidy", "check_clang_tidy.py")
80config.substitutions.append(
81 ('%check_clang_tidy',
Reid Klecknerb250a622019-06-21 18:17:0482 '%s %s' % (python_exec, check_clang_tidy)) )
Stephen Kellya3c42062018-10-01 20:24:2283clang_tidy_diff = os.path.join(
84 config.test_source_root, "..", "clang-tidy", "tool", "clang-tidy-diff.py")
85config.substitutions.append(
86 ('%clang_tidy_diff',
Reid Klecknerb250a622019-06-21 18:17:0487 '%s %s' % (python_exec, clang_tidy_diff)) )
Stephen Kellya3c42062018-10-01 20:24:2288run_clang_tidy = os.path.join(
89 config.test_source_root, "..", "clang-tidy", "tool", "run-clang-tidy.py")
90config.substitutions.append(
91 ('%run_clang_tidy',
Reid Klecknerb250a622019-06-21 18:17:0492 '%s %s' % (python_exec, run_clang_tidy)) )
Kirill Bobyrev73c201d2018-09-12 07:49:4493
Jameson Nash84f137a2022-02-01 17:05:2094config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
95config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
96
97# Plugins (loadable modules)
98if config.has_plugins and config.llvm_plugin_ext:
99 config.available_features.add('plugins')