Files
DongHyeonka d904d680af fix(scripts): 검사 스크립트와 smoke wrapper의 빈틈을 닫고 자기 시험을 더한다
문제:
- README 「새 서비스로 시작하기」의 이름 바꾸기 명령(`git grep -l ... -- src
  scripts`)이 루트 build.gradle·build-logic의 group, config/spotbugs 목록, registry·
  API surface 스냅숏을 놓쳐, 따라 하면 qualityCheck와 surface 검사가 실패했다.
- check-repo-layout.py의 HISTORY_PREFIXES가 없는 폴더 셋(superpowers, evidence,
  study)을 담고 docs/history·docs/design을 빠뜨렸다. 검사 스크립트 머리말에 누가
  부르는지 없었고, check-repo-layout·check-review-index·verify-httpclient-docs에
  자기 시험이 없었다. check-docs.py docstring은 「검사 여섯」(여덟),
  check-work-docs.py는 lychee를 PR workflow라 했다(main).
- run-compose-runtime-smoke.sh가 lane마다 정적 계약 전체를 다시 돌려 nightly마다
  compose config를 수백 번 렌더링했다. handoff lane의 --force-recreate가 1단계
  재시작 수를 지웠고, ps가 빈 결과면 restarts.txt가 비어 재시작 검사가 통과했다.

고친 것:
- 이름 바꾸기 명령을 그 범위로 넓히고 build-logic 자기 패키지는 그대로 둬도
  된다고 적었다.
- HISTORY_PREFIXES를 지금 기록 폴더 넷으로, 머리말에 부르는 곳, docstring 숫자·
  workflow를 고쳤다. 자기 시험 셋을 더했다(scripts/tests 통과, 옛 목록이면
  HISTORY_PREFIXES 시험이 실패한다).
- smoke는 정적 계약을 실행마다 한 번(두 모드 공통) 돌린다. 재시작 수는
  record_restarts가 단계(phase1, final)를 붙여 쌓고, 살핀 컨테이너가 없거나
  inspect·기록이 실패하면 실패한다(호출이 `|| return 1`이라 함수 안 set -e가
  꺼진다).
- verify-httpclient-docs 자기 시험은 실제 트리 대조(release workflow의 검사)를 하지
  않고 누락 탐지만 본다. scripts/tests는 PR 단계에서 돈다.

Refs: RR9-04-04, RR9-04-17, RR9-04-18, RR9-04-26, RR9-04-27
2026-11-13 06:34:33 +09:00

85 lines
2.8 KiB
Python

"""scripts/check-repo-layout.py의 시험. 허용 목록 밖의 항목과 registry 경로를 실패로 보는지 본다.
python3 -m unittest discover -s scripts/tests
"""
from __future__ import annotations
import importlib.util
import json
import sys
import tempfile
import unittest
from pathlib import Path
SCRIPTS = Path(__file__).resolve().parent.parent
_spec = importlib.util.spec_from_file_location("check_repo_layout", SCRIPTS / "check-repo-layout.py")
check_repo_layout = importlib.util.module_from_spec(_spec)
sys.modules["check_repo_layout"] = check_repo_layout
_spec.loader.exec_module(check_repo_layout)
class TopLevelTest(unittest.TestCase):
def test_a_root_entry_outside_the_allow_list_is_not_allowed(self) -> None:
# given
paths = ["AGENTS.md", "stray-notes.txt", "src/domain/core/build.gradle"]
# when
unknown = check_repo_layout.top_level(paths, "") - check_repo_layout.ROOT_ALLOWED.keys()
# then
self.assertEqual(unknown, {"stray-notes.txt"})
def test_a_folder_under_src_that_is_not_a_layer_is_not_allowed(self) -> None:
# given
paths = ["src/domain/core/build.gradle", "src/tools/helper.py"]
# when
unknown = check_repo_layout.top_level(paths, "src/") - check_repo_layout.SRC_ALLOWED.keys()
# then
self.assertEqual(unknown, {"tools"})
class RegistryTest(unittest.TestCase):
def test_a_registry_source_path_outside_the_layer_folders_is_reported(self) -> None:
# given
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
(root / "gradle").mkdir()
modules = [
{"id": "domain-core", "source_path": "src/domain/core"},
{"id": "stray", "source_path": "tools/stray"},
]
(root / check_repo_layout.REGISTRY).write_text(
json.dumps({"modules": modules}), encoding="utf-8"
)
original = check_repo_layout.REPO_ROOT
check_repo_layout.REPO_ROOT = root
try:
# when
problems = check_repo_layout.registry_violations()
finally:
check_repo_layout.REPO_ROOT = original
# then
self.assertEqual(len(problems), 1)
self.assertIn("stray", problems[0])
class HistoryPrefixesTest(unittest.TestCase):
def test_every_history_prefix_is_a_folder_that_exists(self) -> None:
# when
missing = [
prefix
for prefix in check_repo_layout.HISTORY_PREFIXES
if not (check_repo_layout.REPO_ROOT / prefix).is_dir()
]
# then
self.assertEqual(missing, [], "a prefix for a folder that is gone excludes nothing")
if __name__ == "__main__":
unittest.main()