Chandler Carruth | c5062dc | 2012-08-07 07:09:14 | [diff] [blame] | 1 | # -*- Python -*- |
| 2 | |
| 3 | import os |
Sam McCall | 7f0df31 | 2022-03-10 22:57:05 | [diff] [blame] | 4 | import shlex |
Chandler Carruth | c5062dc | 2012-08-07 07:09:14 | [diff] [blame] | 5 | |
Daniel Dunbar | 4d0a3ef | 2013-08-09 18:49:22 | [diff] [blame] | 6 | import lit.formats |
Chandler Carruth | c5062dc | 2012-08-07 07:09:14 | [diff] [blame] | 7 | |
Sam McCall | 69924cc | 2022-03-10 22:09:46 | [diff] [blame] | 8 | from lit.llvm import llvm_config |
| 9 | |
Chandler Carruth | c5062dc | 2012-08-07 07:09:14 | [diff] [blame] | 10 | # Configuration file for the 'lit' test runner. |
| 11 | |
Chandler Carruth | 074a356 | 2013-03-07 10:09:47 | [diff] [blame] | 12 | # name: The name of this test suite. |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 13 | config.name = "Clang Tools" |
Chandler Carruth | 074a356 | 2013-03-07 10:09:47 | [diff] [blame] | 14 | |
Chandler Carruth | c5062dc | 2012-08-07 07:09:14 | [diff] [blame] | 15 | # testFormat: The test format to use to interpret tests. |
Sam McCall | 69924cc | 2022-03-10 22:09:46 | [diff] [blame] | 16 | config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) |
Chandler Carruth | c5062dc | 2012-08-07 07:09:14 | [diff] [blame] | 17 | |
| 18 | # suffixes: A list of file extensions to treat as test files. |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 19 | config.suffixes = [ |
| 20 | ".c", |
| 21 | ".cpp", |
| 22 | ".hpp", |
| 23 | ".m", |
| 24 | ".mm", |
| 25 | ".cu", |
| 26 | ".ll", |
| 27 | ".cl", |
| 28 | ".s", |
| 29 | ".modularize", |
| 30 | ".module-map-checker", |
| 31 | ".test", |
| 32 | ] |
Chandler Carruth | c5062dc | 2012-08-07 07:09:14 | [diff] [blame] | 33 | |
Edwin Vane | 9f7a1c1 | 2013-08-22 19:44:07 | [diff] [blame] | 34 | # Test-time dependencies located in directories called 'Inputs' are excluded |
| 35 | # from test suites; there won't be any lit tests within them. |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 36 | config.excludes = ["Inputs"] |
Edwin Vane | 9f7a1c1 | 2013-08-22 19:44:07 | [diff] [blame] | 37 | |
Chandler Carruth | 074a356 | 2013-03-07 10:09:47 | [diff] [blame] | 38 | # test_source_root: The root path where tests are located. |
| 39 | config.test_source_root = os.path.dirname(__file__) |
| 40 | |
| 41 | # test_exec_root: The root path where tests should be run. |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 42 | config.test_exec_root = os.path.join(config.clang_tools_binary_dir, "test") |
Chandler Carruth | 074a356 | 2013-03-07 10:09:47 | [diff] [blame] | 43 | |
Sam McCall | 2b69eb4 | 2022-03-10 23:29:10 | [diff] [blame] | 44 | # Tools need the same environment setup as clang (we don't need clang itself). |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 45 | llvm_config.use_clang(required=False) |
David Blaikie | d7086fb | 2012-09-04 22:23:37 | [diff] [blame] | 46 | |
Nico Weber | 33c9dbb | 2020-09-03 23:37:29 | [diff] [blame] | 47 | if config.clang_tidy_staticanalyzer: |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 48 | config.available_features.add("static-analyzer") |
Stephen Kelly | a3c4206 | 2018-10-01 20:24:22 | [diff] [blame] | 49 | |
Sam McCall | 7f0df31 | 2022-03-10 22:57:05 | [diff] [blame] | 50 | python_exec = shlex.quote(config.python_executable) |
Stephen Kelly | a3c4206 | 2018-10-01 20:24:22 | [diff] [blame] | 51 | check_clang_tidy = os.path.join( |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 52 | config.test_source_root, "clang-tidy", "check_clang_tidy.py" |
| 53 | ) |
Stephen Kelly | a3c4206 | 2018-10-01 20:24:22 | [diff] [blame] | 54 | config.substitutions.append( |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 55 | ("%check_clang_tidy", "%s %s" % (python_exec, check_clang_tidy)) |
| 56 | ) |
Stephen Kelly | a3c4206 | 2018-10-01 20:24:22 | [diff] [blame] | 57 | clang_tidy_diff = os.path.join( |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 58 | config.test_source_root, "..", "clang-tidy", "tool", "clang-tidy-diff.py" |
| 59 | ) |
Stephen Kelly | a3c4206 | 2018-10-01 20:24:22 | [diff] [blame] | 60 | config.substitutions.append( |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 61 | ("%clang_tidy_diff", "%s %s" % (python_exec, clang_tidy_diff)) |
| 62 | ) |
Stephen Kelly | a3c4206 | 2018-10-01 20:24:22 | [diff] [blame] | 63 | run_clang_tidy = os.path.join( |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 64 | config.test_source_root, "..", "clang-tidy", "tool", "run-clang-tidy.py" |
| 65 | ) |
Stephen Kelly | a3c4206 | 2018-10-01 20:24:22 | [diff] [blame] | 66 | config.substitutions.append( |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 67 | ("%run_clang_tidy", "%s %s" % (python_exec, run_clang_tidy)) |
| 68 | ) |
Richard | 89a1d03 | 2022-06-17 01:02:47 | [diff] [blame] | 69 | clang_tidy_headers = os.path.join( |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 70 | config.test_source_root, "clang-tidy", "checkers", "Inputs", "Headers" |
| 71 | ) |
| 72 | config.substitutions.append(("%clang_tidy_headers", clang_tidy_headers)) |
Kirill Bobyrev | 73c201d | 2018-09-12 07:49:44 | [diff] [blame] | 73 | |
Jameson Nash | 84f137a | 2022-02-01 17:05:20 | [diff] [blame] | 74 | # Plugins (loadable modules) |
| 75 | if config.has_plugins and config.llvm_plugin_ext: |
Tobias Hieta | dd3c26a | 2023-05-17 08:56:49 | [diff] [blame] | 76 | config.available_features.add("plugins") |
Michał Górny | 52ce677 | 2022-10-04 14:36:15 | [diff] [blame] | 77 | |
| 78 | # It is not realistically possible to account for all options that could |
| 79 | # possibly be present in system and user configuration files, so disable |
| 80 | # default configs for the test runs. |
| 81 | config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1" |