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.
This commit is contained in:
Nico Weber 2020-10-29 20:12:50 -04:00
parent db60e64036
commit f1e0944fe5
1 changed files with 3 additions and 3 deletions

View File

@ -61,12 +61,12 @@ def run_test_once(args, extra_args):
clang_extra_args = clang_tidy_extra_args[i + 1:] clang_extra_args = clang_tidy_extra_args[i + 1:]
clang_tidy_extra_args = clang_tidy_extra_args[:i] 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 # autodetection logic can discover a ".clang-tidy" file that is not related to
# the test. # the test.
if not any( if not any(
[arg.startswith('-format-style=') for arg in clang_tidy_extra_args]): [arg.startswith('-config=') for arg in clang_tidy_extra_args]):
clang_tidy_extra_args.append('-format-style=none') clang_tidy_extra_args.append('-config={}')
if extension in ['.m', '.mm']: if extension in ['.m', '.mm']:
clang_extra_args = ['-fobjc-abi-version=2', '-fobjc-arc', '-fblocks'] + \ clang_extra_args = ['-fobjc-abi-version=2', '-fobjc-arc', '-fblocks'] + \