feat(match): 同步比赛计时与装甲板扣血许可
- feat(client): 增加裁判比赛计时、技术暂停与选手端局域网同步 - feat(armor): 红蓝共用通用固件,按客户端选队并显示网络连接状态 - feat(armor): 仅在对局进行中允许扣血,其他阶段保留受击闪烁 - feat(client): 将计时置于血条中间并增加开赛前五秒全屏动画 - fix(client): 修复连续血条、对手镜像和图传断连灰度遮罩 - fix(client): 统一界面中文字体并整理各页面文案 - fix(maintenance): 备份迁移装甲板分区,恢复 SDK 构建与固件打包 - refactor(repo): 按 armor、vt 和 client 整理工程与脚本,移除旧参考实现 - test: 补充线路、受击许可、回环 UDP、维护和 HUD 验证 - docs: 同步构建、协议、比赛控制和硬件验证边界 验证:前端构建与 19 项相关测试通过;核心 91 项单元测试与 2 项回环 UDP 集成测试通过;装甲板规则 25 项、线路 26 项、Tauri 51 项测试通过;独立探测器 5 项与目录回归 4 项通过。完成 C3 两组阈值实际编译、导出与 ZIP 校验,检查 900×600 / 1280×720 页面、倒计时和随包中文字体。 未执行烧录、板上运行、跨电脑广播或硬件稳定性验证。
This commit is contained in:
581 files changed
+6596
-7683
No files matched your search
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env python3
|
||||
"""验证三个工程的目录边界、共享依赖、文档链接及版本生成位置;不连接硬件。"""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from urllib.parse import unquote, urlsplit
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def run(*args, cwd=ROOT):
|
||||
return subprocess.run(args, cwd=cwd, text=True, encoding="utf-8", capture_output=True, check=True)
|
||||
|
||||
|
||||
def heading_ids(text):
|
||||
seen = {}
|
||||
result = set()
|
||||
fenced = False
|
||||
for line in text.splitlines():
|
||||
if line.startswith(("```", "~~~")):
|
||||
fenced = not fenced
|
||||
if fenced or not re.match(r"^#{1,6} ", line):
|
||||
continue
|
||||
title = re.sub(r"^#{1,6} +", "", line).strip().lower()
|
||||
title = re.sub(r"<[^>]+>", "", title)
|
||||
slug = re.sub(r"[^\w\-\s]", "", title).replace(" ", "-")
|
||||
duplicate = seen.get(slug, 0)
|
||||
seen[slug] = duplicate + 1
|
||||
result.add(f"{slug}-{duplicate}" if duplicate else slug)
|
||||
return result
|
||||
|
||||
|
||||
class RepositoryLayoutTests(unittest.TestCase):
|
||||
def test_product_boundaries_and_shared_protocol(self):
|
||||
for removed in ("desktop", "reference", "src", "components", "protocol", "Cargo.toml", ".cargo"):
|
||||
self.assertFalse((ROOT / removed).exists(), removed)
|
||||
for manifest in ("vt/Cargo.toml", "armor/Cargo.toml", "client/core/Cargo.toml", "client/src-tauri/Cargo.toml"):
|
||||
self.assertTrue((ROOT / manifest).is_file(), manifest)
|
||||
shared = (ROOT / "vt/protocol").resolve()
|
||||
for manifest in ("client/core/Cargo.toml", "client/src-tauri/Cargo.toml", "armor/armor-protocol/Cargo.toml"):
|
||||
path = ROOT / manifest
|
||||
dependency = re.search(r'^protocol\s*=\s*\{\s*path\s*=\s*"([^"]+)"', path.read_text(encoding="utf-8"), re.M)
|
||||
self.assertIsNotNone(dependency, manifest)
|
||||
self.assertEqual((path.parent / dependency[1]).resolve(), shared, manifest)
|
||||
|
||||
def test_credentials_and_build_caches_do_not_hide_camera_sources(self):
|
||||
for private in ("vt/.env", "armor/.env", "vt/target/fixture", "client/node_modules/fixture", "armor/target/fixture"):
|
||||
result = subprocess.run(["git", "check-ignore", "-q", private], cwd=ROOT)
|
||||
self.assertEqual(result.returncode, 0, private)
|
||||
for source in ("vt/components/esp32-camera/target/esp32s3/ll_cam.c", "vt/sdkconfig.defaults", "armor/armor-firmware/sdkconfig.defaults"):
|
||||
self.assertTrue((ROOT / source).is_file(), source)
|
||||
result = subprocess.run(["git", "check-ignore", "--no-index", "-q", source], cwd=ROOT)
|
||||
self.assertEqual(result.returncode, 1, source)
|
||||
|
||||
def test_active_document_links(self):
|
||||
documents = [ROOT / name for name in ("README.md", "AGENTS.md", "vt/README.md", "vt/protocol/README.md", "armor/README.md", "client/README.md")]
|
||||
documents += [p for p in (ROOT / "docs").rglob("*.md") if not {"releases", "simba_docs"}.intersection(p.parts)]
|
||||
failures = []
|
||||
for document in documents:
|
||||
text = document.read_text(encoding="utf-8")
|
||||
for match in re.finditer(r"!?\[[^\]\n]*\]\(([^)\n]+)\)", text):
|
||||
target = match[1].strip().strip("<>")
|
||||
parsed = urlsplit(target)
|
||||
if parsed.scheme or parsed.netloc:
|
||||
continue
|
||||
path = (document.parent / unquote(parsed.path)).resolve() if parsed.path else document
|
||||
if not path.exists():
|
||||
failures.append(f"{document.relative_to(ROOT)}: {target}")
|
||||
elif parsed.fragment and path.suffix == ".md" and unquote(parsed.fragment) not in heading_ids(path.read_text(encoding="utf-8")):
|
||||
failures.append(f"{document.relative_to(ROOT)}: missing anchor {target}")
|
||||
self.assertEqual(failures, [], "\n".join(failures))
|
||||
|
||||
def test_version_generation_is_repeatable_and_uses_new_paths(self):
|
||||
with tempfile.TemporaryDirectory(prefix="rmic-version-layout-") as folder:
|
||||
fixture = Path(folder)
|
||||
(fixture / "scripts").mkdir()
|
||||
shutil.copyfile(ROOT / "scripts/version.mjs", fixture / "scripts/version.mjs")
|
||||
(fixture / "vt/protocol/src").mkdir(parents=True)
|
||||
(fixture / "vt/protocol/src/lib.rs").write_text("pub const PROTOCOL_VERSION: u16 = 7;\n", encoding="utf-8")
|
||||
for manifest in ("client/package.json", "client/src-tauri/tauri.conf.json"):
|
||||
destination = fixture / manifest
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
destination.write_text('{"version":"0.0.0"}\n', encoding="utf-8")
|
||||
run("git", "init", "-q", "--initial-branch=main", cwd=fixture)
|
||||
run("git", "add", ".", cwd=fixture)
|
||||
run("git", "-c", "core.hooksPath=" + str(fixture / "empty-hooks"), "-c", "commit.gpgsign=false", "-c", "user.name=Layout Test", "-c", "user.email=layout-test@example.invalid", "commit", "-qm", "feat(layout): fixture", cwd=fixture)
|
||||
run("node", "scripts/version.mjs", "--write", cwd=fixture)
|
||||
outputs = ("version.json", "client/src/lib/version.ts", "client/package.json", "client/src-tauri/tauri.conf.json", "docs/releases/changelog.md", "docs/releases/changelog.json")
|
||||
first = {name: (fixture / name).read_bytes() for name in outputs}
|
||||
run("node", "../scripts/version.mjs", "--write", cwd=fixture / "client")
|
||||
self.assertEqual(first, {name: (fixture / name).read_bytes() for name in outputs})
|
||||
run("node", "scripts/version.mjs", "--check", cwd=fixture)
|
||||
self.assertEqual(json.loads(first["version.json"])["protocol"], 7)
|
||||
self.assertFalse((fixture / "desktop").exists())
|
||||
self.assertFalse((fixture / "changelog.md").exists())
|
||||
self.assertFalse((fixture / "changelog.json").exists())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user