Files
workbuddy_skills/oil-ui-pro/tests/test_build_cards.py
T
admin d9445b5888 oil-ui-pro 0.15.4 → 0.22.2(上游 ui.oiloil.org 正式包)+ 记 P0-98 跨盘 rename 坑
- oil-ui-pro 升到 0.22.2:references 13→28 份(新增 16、删 imagery.md)、assets 增 cards/(22 组)与 fonts/、SKILL.md 顶层五步结构未改名。
- 升级路径:官方 `npx github:oil-oil/oil-cli update` 稳定失败(error=replace、报「检查目录权限」)。
  真身为 EXDEV —— 解压在 os.tmpdir()(C 盘)、技能目录在 E 盘,Windows 上 rename 不能跨盘;
  CLI 的 catch 把非 CliError 原生异常一律兜底成 replaceFailed,真错误一个字不吐。
  做法=借其 prepare() 只做下载+校验,再 cp 到同盘 stage、rename 交换;官方命令复验 up_to_date。
- 回归:product-planning 按名引用的 visual-review.md/tools.md/design-direction.md/style-explorer.md 全部健在;命名闸门 2061|0|27。
- session-mechanism/references/pitfalls.md 新增 P0-98(含通则:更新器把原生错误兜底成指错方向的人话)。
2026-10-14 10:21:46 +08:00

48 lines
1.8 KiB
Python

"""The card gallery builder only rebuilds when it is run without arguments."""
from pathlib import Path
import subprocess
import sys
import unittest
ROOT = Path(__file__).resolve().parents[1]
SCRIPT = ROOT / "scripts" / "build_cards.py"
GALLERY = ROOT / "assets" / "cards" / "gallery.html"
@unittest.skipUnless(SCRIPT.is_file() and GALLERY.is_file(), "card gallery is not part of this edition")
class CardGalleryBuilderTests(unittest.TestCase):
def run_script(self, *args):
return subprocess.run([sys.executable, str(SCRIPT), *args], capture_output=True, text=True, encoding="utf-8")
def test_help_explains_the_script_without_rebuilding(self):
before = GALLERY.stat().st_mtime_ns
run = self.run_script("--help")
self.assertEqual(run.returncode, 0)
self.assertIn("gallery.html", run.stdout)
self.assertNotIn("Built", run.stdout)
self.assertEqual(GALLERY.stat().st_mtime_ns, before)
def test_stray_arguments_are_rejected_without_rebuilding(self):
before = GALLERY.stat().st_mtime_ns
run = self.run_script("cards.json")
self.assertNotEqual(run.returncode, 0)
self.assertEqual(GALLERY.stat().st_mtime_ns, before)
def test_committed_gallery_matches_the_sources(self):
generated = [GALLERY, GALLERY.parent / "shared" / "land-mask.js"]
before = {path: path.read_bytes() for path in generated}
try:
run = self.run_script()
self.assertEqual(run.returncode, 0, run.stderr)
for path in generated:
self.assertEqual(path.read_bytes(), before[path], f"{path.name} is stale; rebuild it with scripts/build_cards.py")
finally:
for path, content in before.items():
path.write_bytes(content)
if __name__ == "__main__":
unittest.main()