feat: add complete yiyezhqiu productivity suite

This commit is contained in:
阿白叔 committed 2026-10-10 17:10:32 +08:00
commit e422ca8b2a
155 files changed
+18959

No files matched your search

+145
View File
@@ -0,0 +1,145 @@
import hashlib
import json
import os
from pathlib import Path
import shutil
import subprocess
REPO_ROOT = Path(__file__).resolve().parents[2]
RELEASE_ROOT = REPO_ROOT / "release" / "DxDesigner效率工具"
def _sanitized_environment() -> dict[str, str]:
environment = os.environ.copy()
windows = Path(os.environ.get("WINDIR", "C:/Windows"))
environment["PATH"] = os.pathsep.join(
(str(windows / "System32"), str(windows))
)
environment["QT_QPA_PLATFORM"] = "offscreen"
environment.pop("PYTHONHOME", None)
environment.pop("PYTHONPATH", None)
return environment
def test_release_contains_portable_runtime_and_root_scripts() -> None:
expected = (
"DxDesignerTools.exe",
"_runtime/python312.dll",
"_runtime/PySide6/plugins/platforms/qwindows.dll",
"_runtime/vbs/BridgeCommon.vbs",
"_runtime/vbs/Snapshot.vbs",
"_runtime/vbs/Transaction.vbs",
"_runtime/vbs/Mailbox.vbs",
"_runtime/vbs/BomExport.vbs",
"MenuAdd.vbs",
"DesignBridge.vbs",
"CompatibilityProbe.vbs",
"templates/BOM模板.xls",
"expedition/ExpeditionBridge.vbs",
"docs/DxDesigner_7.9.5_自动位号工具使用说明.docx",
)
for relative_path in expected:
assert (RELEASE_ROOT / relative_path).is_file(), relative_path
assert any(
path.suffix in {".ttf", ".otf"}
for path in (RELEASE_ROOT / "_runtime").rglob("*")
)
def test_release_does_not_bundle_foreign_icu_from_build_path() -> None:
runtime = RELEASE_ROOT / "_runtime"
assert not (runtime / "icuuc.dll").exists()
assert not list(runtime.glob("icudt*.dll"))
def test_packaged_probe_runs_without_python_on_path(tmp_path: Path) -> None:
output = tmp_path / "兼容性 结果.json"
result = subprocess.run(
[
str(RELEASE_ROOT / "DxDesignerTools.exe"),
"probe",
"--output",
str(output),
"--route",
"named",
"--payload-json",
'{"portable":true}',
],
env=_sanitized_environment(),
timeout=30,
check=False,
)
assert result.returncode == 0
assert json.loads(output.read_text(encoding="utf-8"))["portable"] is True
def test_packaged_ui_loads_request_without_python_on_path() -> None:
result = subprocess.run(
[
str(RELEASE_ROOT / "DxDesignerTools.exe"),
"ui",
"--request",
str(REPO_ROOT / "tests" / "fixtures" / "request-basic.json"),
"--smoke-test-ms",
"250",
],
env=_sanitized_environment(),
timeout=30,
check=False,
)
assert result.returncode == 0
def test_packaged_application_runs_from_chinese_path_with_spaces(
tmp_path: Path,
) -> None:
copied_root = tmp_path / "中文 工具"
shutil.copytree(RELEASE_ROOT, copied_root)
output = tmp_path / "兼容性 结果.json"
probe = subprocess.run(
[
str(copied_root / "DxDesignerTools.exe"),
"probe",
"--output",
str(output),
"--route",
"named",
"--payload-json",
'{"portable":true}',
],
env=_sanitized_environment(),
timeout=30,
check=False,
)
ui = subprocess.run(
[
str(copied_root / "DxDesignerTools.exe"),
"ui",
"--request",
str(REPO_ROOT / "tests" / "fixtures" / "request-basic.json"),
"--smoke-test-ms",
"250",
],
env=_sanitized_environment(),
timeout=30,
check=False,
)
assert probe.returncode == 0
assert json.loads(output.read_text(encoding="utf-8"))["portable"] is True
assert ui.returncode == 0
def test_release_archive_matches_sha256_manifest() -> None:
archive = REPO_ROOT / "release" / "DxDesigner效率工具_Win11_x64.zip"
manifest = REPO_ROOT / "release" / "SHA256SUMS.txt"
digest = hashlib.sha256(archive.read_bytes()).hexdigest()
assert manifest.read_text(encoding="utf-8").split()[0] == digest
@@ -0,0 +1,69 @@
from pathlib import Path
def test_spec_builds_onedir_with_private_runtime() -> None:
text = Path("packaging/DxDesignerTools.spec").read_text(encoding="utf-8")
assert "COLLECT(" in text
assert 'contents_directory="_runtime"' in text
assert 'name="DxDesignerTools"' in text
assert "console=False" in text
def test_build_script_assembles_portable_root_without_installing_packages() -> None:
text = Path("packaging/build_release.ps1").read_text(encoding="utf-8")
for name in (
"MenuAdd.vbs",
"DesignBridge.vbs",
"CompatibilityProbe.vbs",
"BridgeCommon.vbs",
"Snapshot.vbs",
"Transaction.vbs",
"Mailbox.vbs",
"BomExport.vbs",
"ExpeditionBridge.vbs",
"BOM模板.xls",
"DxDesignerTools.exe",
"DxDesigner效率工具_Win11_x64.zip",
"SHA256SUMS.txt",
):
assert name in text
assert "_runtime\\vbs" in text
assert "Compress-Archive" in text
assert "pip install" not in text.casefold()
assert "Invoke-WebRequest" not in text
def test_build_script_has_utf8_bom_for_windows_powershell_51() -> None:
data = Path("packaging/build_release.ps1").read_bytes()
assert data.startswith(b"\xef\xbb\xbf")
def test_build_dependencies_pin_pyinstaller_major_version() -> None:
text = Path("pyproject.toml").read_text(encoding="utf-8")
assert 'pyinstaller>=6.11,<7' in text
def test_build_script_no_longer_ships_legacy_compat_assets() -> None:
"""The legacy EFM/VBS compat layer is retired; only the BOM template and
the Expedition adapter ship with a release."""
text = Path("packaging/build_release.ps1").read_text(encoding="utf-8")
assert "legacy\\yiyezhqiu" not in text
assert "modules\\legacy" not in text
assert "LegacyMenu.vbs" not in text
assert "RefDesBridge.vbs" not in text
assert "D:\\NET_CHECK" not in text
assert "version.json" in text
assert "update-manifest.template.json" in text
def test_signing_tool_exists_and_is_documented() -> None:
text = Path("packaging/sign_manifest.py").read_text(encoding="utf-8")
assert "Ed25519PrivateKey" in text
assert "--package" in text
assert "--key" in text