Files
MonkeyCode/desktop/scripts/test_makefile_agent_version.py
xiaomakuaiz ddf67706d6 refactor(desktop): 旧 UI 换 daisyUI 5 底座,Win7 通道退役
- desktop/ui 接入 Tailwind 4 + daisyUI 5:styles.css 令牌体系改为桥接
  daisyUI 变量(维持到新工程切换),data-accent 四色体系与生成脚本删除,
  theme 显式 light/dark,防闪色对齐 daisyUI base-100
- check_theme_tokens.py 重写:防闪色与 daisyUI 主题源对账 + 深色覆写 ⊆ :root
- Win7 通道退役:desktop-win7.yml/bundle.win7.conf.json/Cargo.lock.win7/
  regen-win7-lock.sh 删除,发布脚本与测试、CI、文档同步;Chromium 109
  兼容红线作废(execCommand 类回退按 WebKit 理由保留)
2026-08-10 22:47:37 +08:00

66 lines
2.2 KiB
Python

#!/usr/bin/env python3
import pathlib
import subprocess
import tempfile
import unittest
ROOT = pathlib.Path(__file__).resolve().parent.parent
WORKSPACE_ROOT = ROOT.parent
class MakefileAgentVersionTest(unittest.TestCase):
def test_engine_builds_embed_agent_commit_hash(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
agent = pathlib.Path(tmp)
(agent / "cmd" / "ohmyagent").mkdir(parents=True)
(agent / "cmd" / "ohmyagent" / "main.go").write_text(
"package main\nfunc main() {}\n",
encoding="utf-8",
)
subprocess.run(["git", "init", "--quiet"], cwd=agent, check=True)
subprocess.run(["git", "add", "."], cwd=agent, check=True)
subprocess.run(
[
"git",
"-c",
"user.name=Desktop Test",
"-c",
"user.email=desktop-test@example.invalid",
"commit",
"--quiet",
"-m",
"fixture",
],
cwd=agent,
check=True,
)
commit = subprocess.run(
["git", "rev-parse", "--short", "HEAD"],
cwd=agent,
check=True,
capture_output=True,
text=True,
).stdout.strip()
dry_run = subprocess.run(
["make", "--dry-run", "engine-universal", f"OHMYAGENT_SRC={agent}"],
cwd=ROOT,
check=True,
capture_output=True,
text=True,
).stdout
linker_value = f"-X main.Version={commit}"
self.assertEqual(dry_run.count(linker_value), 2)
def test_windows_release_workflow_embeds_agent_commit_hash(self) -> None:
workflow = (WORKSPACE_ROOT / ".github" / "workflows" / "desktop-windows.yml").read_text(encoding="utf-8")
self.assertIn('AGENT_VERSION="$(git rev-parse --short HEAD)"', workflow)
self.assertIn("-X main.Version=${AGENT_VERSION}", workflow)
if __name__ == "__main__":
unittest.main()