clang-tidy: Make tests more hermetic
authorNico Weber <thakis@chromium.org>
Fri, 30 Oct 2020 00:12:50 +0000 (20:12 -0400)
committerNico Weber <thakis@chromium.org>
Fri, 30 Oct 2020 00:14:57 +0000 (20:14 -0400)
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

index 093c2e0..0031d9b 100755 (executable)
@@ -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'] + \