Skip to content

Commit 8f0ce93

Browse files
committed
fix(test): markdown 门禁用例按工具可用性自适应,CI 无 markdownlint 也稳定
1 parent 60393bd commit 8f0ce93

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎openspec/changes/2026-09-21-repair-markdown-gate-and-doc-sync/tasks.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
- [x] 3.1 `scripts/languages.json` 为 markdown 声明 `requiresConfig`。
2020
- [x] 3.2 `scripts/languages.json` 为 yaml 声明 `requiresConfig`。
2121
- [x] 3.3 重新表述 `tests/run_all.py` 中「无 requiresConfig 视为已接入」这条断言——它记录的是「未声明时不做限制」,不是「不得声明」。
22-
- [x] 3.4 新增用例:未接入 → 未验证且不阻塞;已接入 → 正常检查。
22+
- [x] 3.4 新增用例:未接入 → 未验证且不阻塞;已接入 → 正常检查(工具缺失时断言「未验证」分支,CI 无 markdownlint 亦稳定)。
2323
- [x] 3.5 新增用例:未声明前置条件的语言行为不变(防回归)。
2424

2525
## 4. 生成器可复现

‎tests/run_all.py‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ def test_unit():
302302
cfg_yaml = _dl.LANG_COMMANDS["yaml"]
303303
ok("markdown 已声明 requiresConfig", bool(cfg_md.get("requiresConfig")))
304304
ok("yaml 已声明 requiresConfig", bool(cfg_yaml.get("requiresConfig")))
305-
ok("markdown 探活可用(--format + stdin=DEVNULL)", _dl.probe_toolchain(cfg_md)[0])
305+
md_available = _dl.probe_toolchain(cfg_md)[0]
306+
ok("markdown 探活语义正确(装了→可用;没装→不可用且原因含探活退出)",
307+
md_available or "探活" in _dl.probe_toolchain(cfg_md)[1])
306308
bare = Path(tempfile.mkdtemp())
307309
_dl._TOOL_CACHE.clear()
308310
# 前面 {file} 用例遗留的 monkeypatch 会让 requiresConfig 分支永不可达——先还原真身
@@ -317,9 +319,15 @@ def test_unit():
317319
(bare / "bad.md").write_text("text \n") # 行尾空格 → MD009,配置在→真跑
318320
_dl._TOOL_CACHE.clear()
319321
f2, s2 = _run_gate(bare, {})
320-
ok("已接入→markdown 真跑(advisory 告警进 skipped)",
321-
not f2 and any(x.startswith("markdown") and "告警" in x for x in s2),
322-
f"failures={f2} skipped={s2}")
322+
if md_available:
323+
ok("已接入→markdown 真跑(advisory 告警进 skipped)",
324+
not f2 and any(x.startswith("markdown") and "告警" in x for x in s2),
325+
f"failures={f2} skipped={s2}")
326+
else:
327+
# CI 无 markdownlint:已接入但工具缺失 → 未验证(不冒充检查过)
328+
ok("已接入但工具缺失→未验证不阻塞",
329+
not f2 and any(x.startswith("markdown") and "不可用" in x for x in s2),
330+
f"failures={f2} skipped={s2}")
323331
ok("已接入→yaml 仍未接入(无 .yamllint 配置)",
324332
any(x.startswith("yaml") and "未接入" in x for x in s2))
325333
finally:

0 commit comments

Comments
 (0)