Skip to content

Commit 91b1dfd

Browse files
committed
sanity_checks: meson format once per project, not once per file
Since we now have tools/format.py to fix any formatting issues, we only need to report that issues exist, not which file they're in. Run `meson format --check` once per project instead of once per file, improving performance.
1 parent 87e363e commit 91b1dfd

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

tools/sanity_checks.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,9 @@ def test_releases(self) -> None:
307307
if patch_path:
308308
with self.subTest(step='patch_directory'):
309309
self.assertTrue(patch_path.is_dir())
310-
# FIXME: Not all wraps currently complies, only check for wraps we modify.
310+
# Don't recheck unchanged projects that may have
311+
# been formatted with an older Meson. Also, format
312+
# checks are slow.
311313
if extra_checks:
312314
self.check_files(name, patch_path)
313315

@@ -666,25 +668,21 @@ def get_default_options(self, project: dict[str, T.Any]) -> dict[str, str | None
666668

667669
def check_files(self, subproject: str, patch_path: Path) -> None:
668670
not_permitted: list[Path] = []
669-
unformatted: list[Path] = []
671+
check_format: list[Path] = []
670672
for f in patch_path.rglob('*'):
671673
if f.is_dir():
672674
continue
673675
if f.name in FORMAT_CHECK_FILES:
674-
try:
675-
format_meson([f], check=True)
676-
except FormattingError:
677-
unformatted.append(f)
676+
check_format.append(f)
678677
if not self.is_permitted_file(subproject, f.name):
679678
not_permitted.append(f)
680679
if not_permitted:
681680
not_permitted_str = ', '.join([str(f) for f in not_permitted])
682681
self.fail(f'Not permitted files found: {not_permitted_str}')
683-
if unformatted:
684-
unformatted_str = ', '.join([str(f) for f in unformatted])
685-
self.fail(
686-
f'''Not formatted files found: {unformatted_str}
687-
Run tools/format.py to format these files.''')
682+
try:
683+
format_meson(check_format, check=True)
684+
except FormattingError:
685+
self.fail('Unformatted files found. Run tools/format.py to format these files.')
688686

689687
@unittest.skipUnless('TEST_MESON_VERSION_DEPS' in os.environ, 'Run manually only')
690688
def test_meson_version_deps(self) -> None:

0 commit comments

Comments
 (0)