[libcxx-commits] [libcxx] f70a81c - [libc++] Add clang-tidy to the list of possible substitutions for %{clang-tidy}
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 12 15:16:45 PST 2023
Author: Nikolas Klauser
Date: 2023-01-13T00:16:37+01:00
New Revision: f70a81cced3a45594c40affd7fd94792bdf2d5d2
URL: https://github.com/llvm/llvm-project/commit/f70a81cced3a45594c40affd7fd94792bdf2d5d2
DIFF: https://github.com/llvm/llvm-project/commit/f70a81cced3a45594c40affd7fd94792bdf2d5d2.diff
LOG: [libc++] Add clang-tidy to the list of possible substitutions for %{clang-tidy}
Most people don't have a versioned clang-tidy locally. This allows them to still run the clang-tidy test if they have a suitable version.
Reviewed By: ldionne, #libc
Spies: libcxx-commits, arichardson
Differential Revision: https://reviews.llvm.org/D141241
Added:
Modified:
libcxx/utils/libcxx/test/features.py
Removed:
################################################################################
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 094608c2a16ee..ad2089bdde4dd 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -18,6 +18,22 @@
_isMSVC = lambda cfg: '_MSC_VER' in compilerMacros(cfg)
_msvcVersion = lambda cfg: (int(compilerMacros(cfg)['_MSC_VER']) // 100, int(compilerMacros(cfg)['_MSC_VER']) % 100)
+def _getSuitableClangTidy(cfg):
+ try:
+ # If we didn't build the libcxx-tidy plugin via CMake, we can't run the clang-tidy tests.
+ if runScriptExitCode(cfg, ['stat %{test-tools}/clang_tidy_checks/libcxx-tidy.plugin']) != 0:
+ return None
+
+ # TODO This should be the last stable release.
+ if runScriptExitCode(cfg, ['clang-tidy-16 --version']) == 0:
+ return 'clang-tidy-16'
+
+ if int(re.search('[0-9]+', commandOutput(cfg, ['clang-tidy --version'])).group()) >= 16:
+ return 'clang-tidy'
+
+ except ConfigurationRuntimeError:
+ return None
+
DEFAULT_FEATURES = [
Feature(name='fcoroutines-ts',
when=lambda cfg: hasCompileFlag(cfg, '-fcoroutines-ts') and
@@ -141,10 +157,8 @@
Feature(name='executor-has-no-bash',
when=lambda cfg: runScriptExitCode(cfg, ['%{exec} bash -c \'bash --version\'']) != 0),
Feature(name='has-clang-tidy',
- # TODO This should be the last stable release.
- when=lambda cfg: runScriptExitCode(cfg, ['clang-tidy-16 --version']) == 0 and
- runScriptExitCode(cfg, ['stat %{test-tools}/clang_tidy_checks/libcxx-tidy.plugin']) == 0,
- actions=[AddSubstitution('%{clang-tidy}', 'clang-tidy-16')]),
+ when=lambda cfg: _getSuitableClangTidy(cfg) is not None,
+ actions=[AddSubstitution('%{clang-tidy}', lambda cfg: _getSuitableClangTidy(cfg))]),
Feature(name='has-clang-query',
when=lambda cfg: runScriptExitCode(cfg, ['clang-query-15 --version']) == 0,
actions=[AddSubstitution('%{clang-query}', 'clang-query-15')]),
More information about the libcxx-commits
mailing list