Files
computer-playbook/tests/integration/meta/cli/test_help.py
kevinveenbirkenbachandClaude Opus 5 5137465c6f style: delete every comment the comments-valid policy rejects
3529 invalid comments in 528 files, grandfathered in while the linter
only saw the working-tree diff. Removal ran through the linter's own
collectors, so detection and deletion cannot drift: a comment whose
opener line is blank before it and whose closer line is blank after it
loses all its lines, anything else loses only the comment region, and a
line left holding a bare delimiter goes with it.

Five files keep their comments behind a nocheck marker instead. Four are
upstream configs whose inline docs are upstream's own (mautrix, systemd
journald, nextcloud-oidc-login, MediaWiki). In littlejs the
commented-out entries ARE the deactivation mechanism for an example
tile, so deleting them would delete configuration.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 03:22:02 +02:00

65 lines
2.0 KiB
Python

import os
import subprocess
import sys
import unittest
from pathlib import Path
class CLIHelpIntegrationTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
from . import PROJECT_ROOT
cls.project_root = str(PROJECT_ROOT)
cls.cli_dir = str(PROJECT_ROOT / "cli")
cls.main_py = str(PROJECT_ROOT / "cli" / "__main__.py")
cls.python = sys.executable
def _discover_command_dirs(self):
"""
Discover commands as package directories under cli/ that contain __main__.py.
Rules:
- cli/<...>/__main__.py marks a command package
- cli/__main__.py is the dispatcher, not a command
- ignore __pycache__
Returns:
list[list[str]] command segments, e.g. ["deploy","container"]
"""
commands = []
for root, dirnames, filenames in os.walk(self.cli_dir): # nocheck: project-walk
dirnames[:] = [d for d in dirnames if d != "__pycache__"]
if "__main__.py" not in filenames:
continue
rel_dir = os.path.relpath(root, self.cli_dir)
if rel_dir == ".":
continue
commands.append(list(Path(rel_dir).parts))
commands.sort(key="/".join)
return commands
def test_all_cli_commands_help(self):
for segments in self._discover_command_dirs():
with self.subTest(command=" ".join(segments)):
cmd = [self.python, self.main_py, *segments, "--help"]
result = subprocess.run(
cmd, capture_output=True, text=True, check=False
)
self.assertEqual(
result.returncode,
0,
msg=(
f"Command `{' '.join(cmd)}` failed\n"
f"stdout:\n{result.stdout}\n"
f"stderr:\n{result.stderr}"
),
)
if __name__ == "__main__":
unittest.main()