102 lines
3.0 KiB
Python
102 lines
3.0 KiB
Python
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def test_distribution_manifest_blocks_source_and_debug_artifacts():
|
|
from tools.distribution_manifest import find_forbidden_distribution_entries
|
|
|
|
entries = [
|
|
"DouyinGuajiGUI.exe",
|
|
"_internal/python310.dll",
|
|
"assets/fudai_task_count_v2_one_task.png",
|
|
"douyin/core/douyin_fudai.py",
|
|
"artifacts/debug.png",
|
|
"config/config.json",
|
|
"logs/unified.log",
|
|
"pic/debug_captures/a.png",
|
|
"DouyinGuajiGUI/_internal/base_library.zip",
|
|
"_internal/douyin/core/douyin_fudai.py",
|
|
"_internal/cv2/__init__.py",
|
|
]
|
|
|
|
blocked = find_forbidden_distribution_entries(entries)
|
|
|
|
assert "douyin/core/douyin_fudai.py" in blocked
|
|
assert "artifacts/debug.png" in blocked
|
|
assert "config/config.json" in blocked
|
|
assert "logs/unified.log" in blocked
|
|
assert "pic/debug_captures/a.png" in blocked
|
|
assert "DouyinGuajiGUI/_internal/base_library.zip" in blocked
|
|
assert "_internal/douyin/core/douyin_fudai.py" in blocked
|
|
assert "_internal/cv2/__init__.py" not in blocked
|
|
assert "assets/fudai_task_count_v2_one_task.png" not in blocked
|
|
|
|
|
|
def test_distribution_manifest_allows_expected_runtime_shape():
|
|
from tools.distribution_manifest import find_forbidden_distribution_entries
|
|
|
|
entries = [
|
|
"DouyinGuajiGUI.exe",
|
|
"web_gui.exe",
|
|
"run_cli.exe",
|
|
"_internal/base_library.zip",
|
|
"assets/fudai_task_count_v2_one_task.png",
|
|
"webui/index.html",
|
|
"config/README.md",
|
|
"logs/.keep",
|
|
"pic/.keep",
|
|
"state/.keep",
|
|
"license.dat",
|
|
]
|
|
|
|
assert find_forbidden_distribution_entries(entries) == []
|
|
|
|
|
|
def test_distribution_manifest_cli_passes_clean_tree(tmp_path):
|
|
dist = tmp_path / "dist"
|
|
for rel in [
|
|
"DouyinGuajiGUI.exe",
|
|
"web_gui.exe",
|
|
"run_cli.exe",
|
|
"_internal/base_library.zip",
|
|
"assets/fudai_task_count_v2_one_task.png",
|
|
"webui/index.html",
|
|
"config/README.md",
|
|
"logs/.keep",
|
|
"pic/.keep",
|
|
"state/.keep",
|
|
"license.dat",
|
|
]:
|
|
path = dist / rel
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text("x", encoding="utf-8")
|
|
|
|
proc = subprocess.run(
|
|
[sys.executable, "-m", "tools.distribution_manifest", str(dist)],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
|
|
assert proc.returncode == 0
|
|
assert "[DIST-CHECK] PASS" in proc.stdout
|
|
|
|
|
|
def test_distribution_manifest_cli_fails_dirty_tree(tmp_path):
|
|
dist = tmp_path / "dist"
|
|
dirty = dist / "douyin" / "core" / "secret.py"
|
|
dirty.parent.mkdir(parents=True, exist_ok=True)
|
|
dirty.write_text("print('secret')", encoding="utf-8")
|
|
|
|
proc = subprocess.run(
|
|
[sys.executable, "-m", "tools.distribution_manifest", str(dist)],
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
|
|
assert proc.returncode == 2
|
|
assert "douyin/core/secret.py" in proc.stdout
|