diff --git a/scripts/make_site_icons.py b/scripts/make_site_icons.py index 624316184..6f1977458 100644 --- a/scripts/make_site_icons.py +++ b/scripts/make_site_icons.py @@ -28,12 +28,16 @@ The repository's own images come from the same shapes, in ``.github/assets/``: from __future__ import annotations +import argparse + from core.paths import REPO_ROOT from sitegen.brand import write_brand from sitegen.chromium import require_playwright def main() -> None: + parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0], allow_abbrev=False) + parser.parse_args() sync_playwright = require_playwright() for path in write_brand(sync_playwright): print(path.relative_to(REPO_ROOT)) diff --git a/tests/test_tool_messages.py b/tests/test_tool_messages.py index 8598874cb..347744b4a 100644 --- a/tests/test_tool_messages.py +++ b/tests/test_tool_messages.py @@ -1012,5 +1012,21 @@ class CitedCommandsRunWhenPasted(unittest.TestCase): str(caught.exception)) +class EveryCommandReadsItsArguments(unittest.TestCase): + """make_site_icons.py parsed no argument: `--help` launched Chromium and + rewrote nine committed images. A command answers its arguments or refuses + them, never runs past them.""" + + READERS = ("ArgumentParser", "sys.argv", "scraper_cli(", "target_cli(") + + def test_each_entry_point_reads_argv(self): + found = [ + path.name for path in sorted((REPO_ROOT / "scripts").glob("*.py")) + if 'if __name__ == "__main__"' in (text := path.read_text(encoding="utf-8")) + and not any(reader in text for reader in self.READERS) + ] + self.assertEqual(found, []) + + if __name__ == "__main__": unittest.main()