diff --git a/tests/test_build_installer.py b/tests/test_build_installer.py index 96356fd34..72c0b1db6 100644 --- a/tests/test_build_installer.py +++ b/tests/test_build_installer.py @@ -54,6 +54,26 @@ class TheCommittedFileIsTheBuiltOne(unittest.TestCase): if path.name != "__init__.py": self.assertIn("from __future__ import annotations\n", source) + def test_every_module_says_its_concern_in_one_line(self): + for path in sorted((REPO_ROOT / "installer").glob("*.py")): + if path.name == "__init__.py": + continue + docstring = ast.get_docstring(ast.parse(path.read_text(encoding="utf-8")), clean=False) or "" + with self.subTest(module=path.name): + self.assertTrue(docstring.strip()) + self.assertNotIn("\n", docstring) + + def test_the_architecture_page_names_every_module(self): + """wiki/architecture.md groups the modules by concern: a module added, + renamed or merged changes the table in the same commit.""" + page = (REPO_ROOT / "wiki" / "architecture.md").read_text(encoding="utf-8") + section = page.split("## Installer modules", 1)[1].split("\n## ", 1)[0] + listed = [name for row in section.splitlines() if row.startswith("| ") and "`" in row + for name in row.split("|")[2].replace("`", "").replace(",", " ").split()] + modules = sorted(path.stem for path in (REPO_ROOT / "installer").glob("*.py") + if path.name != "__init__.py") + self.assertEqual(sorted(listed), modules) + class JoiningRefusesWhatOneNamespaceCannotHold(unittest.TestCase): def setUp(self): diff --git a/wiki/architecture.md b/wiki/architecture.md index 90b64bba2..71183536d 100644 --- a/wiki/architecture.md +++ b/wiki/architecture.md @@ -467,6 +467,24 @@ The cross-platform installer (`install.py`) uses these manifests to auto-detect user's platform, filter files by hardware target, and download with SHA256/SHA1, size, path-containment and atomic-write checks. +## Installer modules + +Each module of `installer/` holds one concern, named in its first line. +`build_installer.py` refuses an import cycle and joins the modules each after +those it imports: + +| Concern | Modules | +|---------|---------| +| Shared words and limits | `remote`, `regions`, `platforms`, `manifest`, `embedded`, `text`, `events`, `invocation` | +| Terminal and line output | `terminal`, `console` | +| Files and folders | `host_fs`, `paths`, `filesystems`, `config_values`, `local_check`, `safe_replace` | +| This machine | `detect_os`, `detect_frontends`, `cards`, `device`, `cores`, `frontend_folders`, `setups` | +| Sources of files | `offline`, `network`, `pack_source`, `from_folders`, `diagnosis`, `download`, `datadirs`, `standalone` | +| What a run keeps | `narrowing`, `choices`, `romm`, `install_record`, `game_files`, `games`, `tally` | +| Line mode | `destination`, `line_folder`, `line_menu`, `plan_words`, `plan`, `outcome` | +| Runs and actions | `arguments`, `run_setups`, `run_files`, `run`, `pack`, `removal`, `handheld_app`, `cli` | +| Full screen | `tui_state`, `tui_routes`, `tui_commands`, `tui_keys`, `tui_paint`, `tui_choice`, `tui_rows`, `tui_frame`, `tui_plan_view`, `tui_outcome`, `tui_screens`, `tui_actions`, `tui_input`, `tui_receive`, `tui_engine`, `tui_session` | + ## Tests The suite is discovered dynamically rather than maintained as a hand-counted