From c8ccb62a98fbb85eda6ed74eeb0c35f07b484b80 Mon Sep 17 00:00:00 2001 From: QiuSW <105186638@qq.com> Date: Sat, 8 Aug 2026 09:02:48 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E8=A6=86=E7=9B=96=E6=A0=B8=E5=BF=83?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=98=A0=E5=B0=84=E9=94=99=E8=AF=AF=20(#2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/check_harness.py | 16 +++++++++++----- tests/test_harness_docs.py | 8 ++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/scripts/check_harness.py b/scripts/check_harness.py index 8f82dcd..d363d52 100644 --- a/scripts/check_harness.py +++ b/scripts/check_harness.py @@ -165,6 +165,16 @@ def check_task_template(errors: list[str], root: Path = ROOT) -> None: errors.append(f"单元任务模板缺少:{section}") +def core_mapping_errors(configured_mappings: dict[str, str]) -> list[str]: + errors: list[str] = [] + for page, expected_path in CORE_PAGE_PATHS.items(): + if configured_mappings.get(page) != expected_path: + errors.append( + f"核心 Wiki 页面映射缺失或路径错误:{page} -> {expected_path}" + ) + return errors + + def check_wiki_mirrors(errors: list[str]) -> None: """检查每份本地文档都有显式映射和可追踪的镜像头。""" @@ -175,11 +185,7 @@ def check_wiki_mirrors(errors: list[str]) -> None: return configured_mappings = {mapping.page: mapping.path for mapping in config.mappings} - for page, expected_path in CORE_PAGE_PATHS.items(): - if configured_mappings.get(page) != expected_path: - errors.append( - f"核心 Wiki 页面映射缺失或路径错误:{page} -> {expected_path}" - ) + errors.extend(core_mapping_errors(configured_mappings)) mapped_paths = {mapping.path for mapping in config.mappings} actual_paths = { diff --git a/tests/test_harness_docs.py b/tests/test_harness_docs.py index 79f4f32..c15cb31 100644 --- a/tests/test_harness_docs.py +++ b/tests/test_harness_docs.py @@ -14,6 +14,7 @@ from check_harness import ( # noqa: E402 REQUIRED_FILES, check_core_documents, check_task_template, + core_mapping_errors, missing_sections, ) from wiki_docs import load_config # noqa: E402 @@ -39,6 +40,13 @@ class CoreDocumentTests(unittest.TestCase): for page, path in CORE_PAGE_PATHS.items(): self.assertEqual(mappings.get(page), path) + def test_missing_or_wrong_core_mapping_is_reported(self) -> None: + errors = core_mapping_errors({"Home": "docs/wrong.md"}) + self.assertTrue(any("Home -> docs/README.md" in error for error in errors)) + self.assertTrue( + any("Architecture-and-Code-Map" in error for error in errors) + ) + class TaskTemplateTests(unittest.TestCase): def test_task_template_requires_document_impact(self) -> None: