aboutsummaryrefslogtreecommitdiff
path: root/unittests/allplatformstests.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-09-29 14:05:54 -0400
committerXavier Claessens <xclaesse@gmail.com>2021-10-10 14:13:35 -0400
commit32b7cbd4a7cd8cffb47c5465301141eaad599eaa (patch)
tree245fb09ff61454d9afec8c37ef29957f04c5028e /unittests/allplatformstests.py
parent0a3a9fa0c3ebf45c94d9009a59cead571cbecf7b (diff)
downloadmeson-32b7cbd4a7cd8cffb47c5465301141eaad599eaa.zip
meson-32b7cbd4a7cd8cffb47c5465301141eaad599eaa.tar.gz
meson-32b7cbd4a7cd8cffb47c5465301141eaad599eaa.tar.bz2
clangformat: Only format files tracked by git by default
Diffstat (limited to 'unittests/allplatformstests.py')
-rw-r--r--unittests/allplatformstests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py
index 9468fd5..12aefa0 100644
--- a/unittests/allplatformstests.py
+++ b/unittests/allplatformstests.py
@@ -2539,6 +2539,7 @@ class AllPlatformTests(BasePlatformTests):
testheader = os.path.join(testdir, 'header.h')
badheader = os.path.join(testdir, 'header_orig_h')
goodheader = os.path.join(testdir, 'header_expected_h')
+ includefile = os.path.join(testdir, '.clang-format-include')
try:
shutil.copyfile(badfile, testfile)
shutil.copyfile(badheader, testheader)
@@ -2547,6 +2548,17 @@ class AllPlatformTests(BasePlatformTests):
Path(goodfile).read_text(encoding='utf-8'))
self.assertNotEqual(Path(testheader).read_text(encoding='utf-8'),
Path(goodheader).read_text(encoding='utf-8'))
+
+ # test files are not in git so this should do nothing
+ self.run_target('clang-format')
+ self.assertNotEqual(Path(testfile).read_text(encoding='utf-8'),
+ Path(goodfile).read_text(encoding='utf-8'))
+ self.assertNotEqual(Path(testheader).read_text(encoding='utf-8'),
+ Path(goodheader).read_text(encoding='utf-8'))
+
+ # Add an include file to reformat everything
+ with open(includefile, 'w', encoding='utf-8') as f:
+ f.write('*')
self.run_target('clang-format')
self.assertEqual(Path(testheader).read_text(encoding='utf-8'),
Path(goodheader).read_text(encoding='utf-8'))
@@ -2555,6 +2567,8 @@ class AllPlatformTests(BasePlatformTests):
os.unlink(testfile)
if os.path.exists(testheader):
os.unlink(testheader)
+ if os.path.exists(includefile):
+ os.unlink(includefile)
@skipIfNoExecutable('clang-tidy')
def test_clang_tidy(self):