blob: 5c3934fb0b162788879794e7e9dedd699f186db4 [file] [log] [blame]
Chandler Carruthc5062dc2012-08-07 07:09:141# -*- Python -*-
2
3import os
4import platform
5import re
6import subprocess
7
Daniel Dunbar4d0a3ef2013-08-09 18:49:228import lit.formats
9import lit.util
Chandler Carruthc5062dc2012-08-07 07:09:1410
Sam McCall69924cc2022-03-10 22:09:4611from lit.llvm import llvm_config
12
Chandler Carruthc5062dc2012-08-07 07:09:1413# Configuration file for the 'lit' test runner.
14
Chandler Carruth074a3562013-03-07 10:09:4715# name: The name of this test suite.
16config.name = 'Clang Tools'
17
Chandler Carruthc5062dc2012-08-07 07:09:1418# testFormat: The test format to use to interpret tests.
19#
20# For now we require '&&' between commands, until they get globally killed and
21# the test runner updated.
Sam McCall69924cc2022-03-10 22:09:4622config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
Chandler Carruthc5062dc2012-08-07 07:09:1423
24# suffixes: A list of file extensions to treat as test files.
Alexander Kornienkob816ba02016-01-08 16:37:1125config.suffixes = ['.c', '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
Benjamin Kramer03016b82016-05-31 12:12:1926 '.modularize', '.module-map-checker', '.test']
Chandler Carruthc5062dc2012-08-07 07:09:1427
Edwin Vane9f7a1c12013-08-22 19:44:0728# Test-time dependencies located in directories called 'Inputs' are excluded
29# from test suites; there won't be any lit tests within them.
30config.excludes = ['Inputs']
31
Chandler Carruth074a3562013-03-07 10:09:4732# test_source_root: The root path where tests are located.
33config.test_source_root = os.path.dirname(__file__)
34
35# test_exec_root: The root path where tests should be run.
Zachary Turnerce92db12017-09-15 22:10:4636config.test_exec_root = os.path.join(config.clang_tools_binary_dir, 'test')
Chandler Carruth074a3562013-03-07 10:09:4737
Chandler Carruthc5062dc2012-08-07 07:09:1438# Clear some environment variables that might affect Clang.
39#
40# This first set of vars are read by Clang, but shouldn't affect tests
41# that aren't specifically looking for these features, or are required
42# simply to run the tests at all.
43#
44# FIXME: Should we have a tool that enforces this?
45
46# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
47# 'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
48# 'IOS_SIMULATOR_DEPLOYMENT_TARGET',
49# 'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
50# 'VC80COMNTOOLS')
51possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
52 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
53 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
54 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
55 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
56 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
57 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
58 'LIBCLANG_RESOURCE_USAGE',
59 'LIBCLANG_CODE_COMPLETION_LOGGING']
60# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
61if platform.system() != 'Windows':
62 possibly_dangerous_env_vars.append('INCLUDE')
63for name in possibly_dangerous_env_vars:
64 if name in config.environment:
65 del config.environment[name]
66
67# Tweak the PATH to include the tools dir and the scripts dir.
Zachary Turnerce92db12017-09-15 22:10:4668path = os.path.pathsep.join((
69 config.clang_tools_dir, config.llvm_tools_dir, config.environment['PATH']))
70config.environment['PATH'] = path
Chandler Carruthc5062dc2012-08-07 07:09:1471
Zachary Turnerce92db12017-09-15 22:10:4672path = os.path.pathsep.join((config.clang_libs_dir, config.llvm_libs_dir,
73 config.environment.get('LD_LIBRARY_PATH','')))
74config.environment['LD_LIBRARY_PATH'] = path
David Blaikied7086fb2012-09-04 22:23:3775
Chandler Carruthc5062dc2012-08-07 07:09:1476# When running under valgrind, we mangle '-vg' onto the end of the triple so we
77# can check it with XFAIL and XTARGET.
Daniel Dunbar4d0a3ef2013-08-09 18:49:2278if lit_config.useValgrind:
Chandler Carruthc5062dc2012-08-07 07:09:1479 config.target_triple += '-vg'
80
David Carlier7e37bf22019-01-24 07:58:4281config.available_features.add('crash-recovery')
Chandler Carruthc5062dc2012-08-07 07:09:1482# Set available features we allow tests to conditionalize on.
83#
Chandler Carruthc5062dc2012-08-07 07:09:1484
Reid Kleckner558850a2015-05-20 20:33:1885# Exclude MSYS due to transforming '/' to 'X:/mingwroot/'.
86if not platform.system() in ['Windows'] or not execute_external:
87 config.available_features.add('shell-preserves-root')
88
David Blaikie149bf5d2012-09-12 16:29:3789# ANSI escape sequences in non-dumb terminal
Chandler Carruthc5062dc2012-08-07 07:09:1490if platform.system() not in ['Windows']:
91 config.available_features.add('ansi-escape-sequences')
Alexander Kornienko47e8e722014-06-26 16:32:2692
Nico Weber33c9dbb2020-09-03 23:37:2993if config.clang_tidy_staticanalyzer:
Michal Gornya81de442017-08-29 05:58:0894 config.available_features.add('static-analyzer')
Stephen Kellya3c42062018-10-01 20:24:2295
Reid Klecknerb250a622019-06-21 18:17:0496# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
97# it's not available.
98try:
99 import shlex
100 sh_quote = shlex.quote
101except:
102 import pipes
103 sh_quote = pipes.quote
104python_exec = sh_quote(config.python_executable)
105
Stephen Kellya3c42062018-10-01 20:24:22106check_clang_tidy = os.path.join(
107 config.test_source_root, "clang-tidy", "check_clang_tidy.py")
108config.substitutions.append(
109 ('%check_clang_tidy',
Reid Klecknerb250a622019-06-21 18:17:04110 '%s %s' % (python_exec, check_clang_tidy)) )
Stephen Kellya3c42062018-10-01 20:24:22111clang_tidy_diff = os.path.join(
112 config.test_source_root, "..", "clang-tidy", "tool", "clang-tidy-diff.py")
113config.substitutions.append(
114 ('%clang_tidy_diff',
Reid Klecknerb250a622019-06-21 18:17:04115 '%s %s' % (python_exec, clang_tidy_diff)) )
Stephen Kellya3c42062018-10-01 20:24:22116run_clang_tidy = os.path.join(
117 config.test_source_root, "..", "clang-tidy", "tool", "run-clang-tidy.py")
118config.substitutions.append(
119 ('%run_clang_tidy',
Reid Klecknerb250a622019-06-21 18:17:04120 '%s %s' % (python_exec, run_clang_tidy)) )
Kirill Bobyrev73c201d2018-09-12 07:49:44121
122clangd_benchmarks_dir = os.path.join(os.path.dirname(config.clang_tools_dir),
123 "tools", "clang", "tools", "extra",
124 "clangd", "benchmarks")
125config.substitutions.append(('%clangd-benchmark-dir',
126 '%s' % (clangd_benchmarks_dir)))
Jameson Nash84f137a2022-02-01 17:05:20127config.substitutions.append(('%llvmshlibdir', config.clang_libs_dir))
128config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
129
130# Plugins (loadable modules)
131if config.has_plugins and config.llvm_plugin_ext:
132 config.available_features.add('plugins')