[clang-tools-extra] f1e0944 - clang-tidy: Make tests more hermetic

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 29 17:15:07 PDT 2020


Author: Nico Weber
Date: 2020-10-29T20:14:57-04:00
New Revision: f1e0944fe5bbafd99e7cddb0892d6396a7eba01f

URL: https://github.com/llvm/llvm-project/commit/f1e0944fe5bbafd99e7cddb0892d6396a7eba01f
DIFF: https://github.com/llvm/llvm-project/commit/f1e0944fe5bbafd99e7cddb0892d6396a7eba01f.diff

LOG: 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.

Added: 
    

Modified: 
    clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Removed: 
    


################################################################################
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 093c2e059c63..0031d9b04ad1 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'] + \


        


More information about the cfe-commits mailing list