Never run clang-format / clang-tidy against directories

`pathlib.Path.glob()` also returns directories that match source
filenames (i.e. a directory named `test.h/`), but `clang-format` and
`clang-tidy` fail when handed a directory. We manually skip calling
`clang-format` and `clang-tidy` on those directories.
pull/7817/head
Bernd Busse 4 years ago committed by Jussi Pakkanen
parent 4b1c1d83c8
commit c4fa876925
  1. 2
      mesonbuild/scripts/clangformat.py
  2. 2
      mesonbuild/scripts/clangtidy.py
  3. 2
      run_unittests.py
  4. 1
      test cases/unit/54 clang-format/dummydir.h/dummy.dat
  5. 1
      test cases/unit/70 clang-tidy/dummydir.h/dummy.dat

@ -27,6 +27,8 @@ def clangformat(exelist: T.List[str], srcdir_name: str, builddir_name: str) -> i
futures = []
with ThreadPoolExecutor() as e:
for f in (x for suff in suffixes for x in srcdir.glob('**/*.' + suff)):
if f.is_dir():
continue
strf = str(f)
if strf.startswith(builddir_name):
continue

@ -28,6 +28,8 @@ def manual_clangformat(srcdir_name: str, builddir_name: str) -> int:
returncode = 0
with ThreadPoolExecutor() as e:
for f in (x for suff in suffixes for x in srcdir.glob('**/*.' + suff)):
if f.is_dir():
continue
strf = str(f)
if strf.startswith(builddir_name):
continue

@ -4212,9 +4212,11 @@ recommended as it is not supported on some platforms''')
if is_osx():
raise unittest.SkipTest('Apple ships a broken clang-tidy that chokes on -pipe.')
testdir = os.path.join(self.unit_test_dir, '70 clang-tidy')
dummydir = os.path.join(testdir, 'dummydir.h')
self.init(testdir, override_envvars={'CXX': 'c++'})
out = self.run_target('clang-tidy')
self.assertIn('cttest.cpp:4:20', out)
self.assertNotIn(dummydir, out)
def test_identity_cross(self):
testdir = os.path.join(self.unit_test_dir, '71 cross')

@ -0,0 +1 @@
Placeholder to track enclosing directory in git. Not to be analyzed.

@ -0,0 +1 @@
Placeholder to track enclosing directory in git. Not to be analyzed.
Loading…
Cancel
Save