同步移动端工程、设备控制改进与发布资料

This commit is contained in:
2026-09-26 19:21:12 +08:00
parent 912ba432cf
commit 98eadc5c8b
137 changed files with 9274 additions and 85 deletions
@@ -1,6 +1,7 @@
from __future__ import annotations
import importlib.util
import json
from pathlib import Path, PurePosixPath
import pytest
@@ -110,3 +111,30 @@ def test_repository_contract_has_example_and_ignored_private_file():
assert hygiene.EXAMPLE_CREDENTIAL in paths
assert hygiene.PRIVATE_CREDENTIAL not in paths
assert hygiene._check_repository_contract(paths, staged=False) == []
def test_mobile_markers_are_checked_even_without_board_credentials(tmp_path, monkeypatch):
monkeypatch.setattr(hygiene, "WORKSPACE_ROOT", tmp_path)
private = tmp_path.joinpath(*hygiene.PRIVATE_MOBILE_REGISTRATION.parts)
private.parent.mkdir(parents=True)
private.write_text(json.dumps({"devices": [{"serial": "FAKE-SERIAL-PRIVATE-123"}]}), encoding="utf-8")
markers = hygiene._private_value_markers()
assert "FAKE-SERIAL-PRIVATE-123" in markers
assert hygiene._text_issues(PurePosixPath("docs/report.md"), "FAKE-SERIAL-PRIVATE-123", markers)
def test_corrupt_mobile_registration_fails_closed(tmp_path, monkeypatch):
monkeypatch.setattr(hygiene, "WORKSPACE_ROOT", tmp_path)
private = tmp_path.joinpath(*hygiene.PRIVATE_MOBILE_REGISTRATION.parts)
private.parent.mkdir(parents=True)
private.write_text("broken", encoding="utf-8")
with pytest.raises(hygiene.HygieneError, match="移动端真实登记损坏"):
hygiene._private_value_markers()
def test_mobile_private_and_signing_files_are_rejected():
findings = hygiene.audit_paths(
[hygiene.PRIVATE_MOBILE_REGISTRATION, PurePosixPath("keys/debug.keystore")],
scan_binary=False,
)
assert len(findings) == 2