From f1e0944fe5bbafd99e7cddb0892d6396a7eba01f Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 29 Oct 2020 20:12:50 -0400 Subject: [PATCH] clang-tidy: Make tests more hermetic Make check_clang_tidy.py not just pass -format-style=none by default but a full -config={}. Without this, with a build dir outside of the llvm root dir and a .clang-tidy config further up that contains CheckOptions: - key: modernize-use-default-member-init.UseAssignment value: 1 these tests would fail: Clang Tools :: clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init.cpp Clang Tools :: clang-tidy/checkers/modernize-use-default-member-init-bitfield.cpp Clang Tools :: clang-tidy/checkers/modernize-use-default-member-init.cpp After this change, they pass fine, despite the unrelated .clang-tidy file further up. --- clang-tools-extra/test/clang-tidy/check_clang_tidy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py index 093c2e0..0031d9b 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -61,12 +61,12 @@ def run_test_once(args, extra_args): clang_extra_args = clang_tidy_extra_args[i + 1:] clang_tidy_extra_args = clang_tidy_extra_args[:i] - # If the test does not specify a formatting style, force "none"; otherwise + # If the test does not specify a config style, force an empty one; otherwise # autodetection logic can discover a ".clang-tidy" file that is not related to # the test. if not any( - [arg.startswith('-format-style=') for arg in clang_tidy_extra_args]): - clang_tidy_extra_args.append('-format-style=none') + [arg.startswith('-config=') for arg in clang_tidy_extra_args]): + clang_tidy_extra_args.append('-config={}') if extension in ['.m', '.mm']: clang_extra_args = ['-fobjc-abi-version=2', '-fobjc-arc', '-fblocks'] + \ -- 2.7.4