diff options
-rw-r--r-- | mesonbuild/scripts/clangformat.py | 1 | ||||
-rwxr-xr-x | run_unittests.py | 25 | ||||
-rw-r--r-- | test cases/unit/53 clang-format/header_expected_h | 3 | ||||
-rw-r--r-- | test cases/unit/53 clang-format/header_orig_h | 9 |
4 files changed, 28 insertions, 10 deletions
diff --git a/mesonbuild/scripts/clangformat.py b/mesonbuild/scripts/clangformat.py index fcdf5af..351d06b 100644 --- a/mesonbuild/scripts/clangformat.py +++ b/mesonbuild/scripts/clangformat.py @@ -21,6 +21,7 @@ from ..compilers import lang_suffixes def clangformat(srcdir_name, builddir_name): srcdir = pathlib.Path(srcdir_name) suffixes = set(lang_suffixes['c']).union(set(lang_suffixes['cpp'])) + suffixes.add('h') futures = [] with ThreadPoolExecutor() as e: for f in (x for suff in suffixes for x in srcdir.glob('**/*.' + suff)): diff --git a/run_unittests.py b/run_unittests.py index f22a9b2..f381efc 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3271,20 +3271,25 @@ recommended as it is not supported on some platforms''') testfile = os.path.join(testdir, 'prog.c') badfile = os.path.join(testdir, 'prog_orig_c') goodfile = os.path.join(testdir, 'prog_expected_c') + testheader = os.path.join(testdir, 'header.h') + badheader = os.path.join(testdir, 'header_orig_h') + goodheader = os.path.join(testdir, 'header_expected_h') try: - self.run_clangformat(testdir, testfile, badfile, goodfile) + shutil.copyfile(badfile, testfile) + shutil.copyfile(badheader, testheader) + self.init(testdir) + self.assertNotEqual(Path(testfile).read_text(), + Path(goodfile).read_text()) + self.assertNotEqual(Path(testheader).read_text(), + Path(goodheader).read_text()) + self.run_target('clang-format') + self.assertEqual(Path(testheader).read_text(), + Path(goodheader).read_text()) finally: if os.path.exists(testfile): os.unlink(testfile) - - def run_clangformat(self, testdir, testfile, badfile, goodfile): - shutil.copyfile(badfile, testfile) - self.init(testdir) - self.assertNotEqual(Path(testfile).read_text(), - Path(goodfile).read_text()) - self.run_target('clang-format') - self.assertEqual(Path(testfile).read_text(), - Path(goodfile).read_text()) + if os.path.exists(testheader): + os.unlink(testheader) def test_introspect_buildoptions_without_configured_build(self): testdir = os.path.join(self.unit_test_dir, '56 introspect buildoptions') diff --git a/test cases/unit/53 clang-format/header_expected_h b/test cases/unit/53 clang-format/header_expected_h new file mode 100644 index 0000000..4303176 --- /dev/null +++ b/test cases/unit/53 clang-format/header_expected_h @@ -0,0 +1,3 @@ +#pragma once + +int fun(int argc); diff --git a/test cases/unit/53 clang-format/header_orig_h b/test cases/unit/53 clang-format/header_orig_h new file mode 100644 index 0000000..f2222f3 --- /dev/null +++ b/test cases/unit/53 clang-format/header_orig_h @@ -0,0 +1,9 @@ +#pragma once + +int +fun +( +int +argc +) +; |