build: bundle adb platform tools

This commit is contained in:
Your Name committed 2026-06-27 17:59:36 +08:00
1 parent ecbd07cea0
commit f257c4e3fc
11 files changed
+207 -6

No files matched your search

+57
View File
@@ -60,6 +60,9 @@ def test_distribution_manifest_blocks_project_native_binaries_outside_core_allow
"_internal/douyin/fudai/core/compiled.cp312-win_amd64.pyd",
"_internal/numpy/core/runtime.pyd",
"webui/index.html",
"platform-tools/adb.exe",
"platform-tools/AdbWinApi.dll",
"platform-tools/AdbWinUsbApi.dll",
"config/README.md",
"logs/.keep",
"pic/.keep",
@@ -89,6 +92,11 @@ def test_distribution_manifest_allows_expected_runtime_shape():
"webui/index.html",
"webui/css/base.css",
"webui/js/api_client.js",
"platform-tools/adb.exe",
"platform-tools/AdbWinApi.dll",
"platform-tools/AdbWinUsbApi.dll",
"platform-tools/NOTICE.txt",
"platform-tools/source.properties",
"config/README.md",
"logs/.keep",
"pic/.keep",
@@ -98,6 +106,22 @@ def test_distribution_manifest_allows_expected_runtime_shape():
assert find_distribution_issues(entries) == []
def test_distribution_manifest_blocks_unexpected_platform_tools_files():
from tools.distribution_manifest import find_forbidden_distribution_entries
entries = [
"platform-tools/adb.exe",
"platform-tools/fastboot.exe",
"platform-tools/mke2fs.conf",
]
blocked = find_forbidden_distribution_entries(entries)
assert "platform-tools/adb.exe" not in blocked
assert "platform-tools/fastboot.exe" in blocked
assert "platform-tools/mke2fs.conf" in blocked
def test_distribution_manifest_can_allow_license_for_local_test_package():
from tools.distribution_manifest import find_distribution_issues
@@ -109,6 +133,9 @@ def test_distribution_manifest_can_allow_license_for_local_test_package():
"_internal/python312.dll",
"assets/fudai.png",
"webui/index.html",
"platform-tools/adb.exe",
"platform-tools/AdbWinApi.dll",
"platform-tools/AdbWinUsbApi.dll",
"config/README.md",
"logs/.keep",
"pic/.keep",
@@ -130,6 +157,9 @@ def test_distribution_manifest_requires_python_runtime_dll():
"_internal/base_library.zip",
"assets/fudai.png",
"webui/index.html",
"platform-tools/adb.exe",
"platform-tools/AdbWinApi.dll",
"platform-tools/AdbWinUsbApi.dll",
"config/README.md",
"logs/.keep",
"pic/.keep",
@@ -141,6 +171,30 @@ def test_distribution_manifest_requires_python_runtime_dll():
assert "_internal/python*.dll" in issues
def test_distribution_manifest_requires_bundled_adb_runtime():
from tools.distribution_manifest import find_distribution_issues
entries = [
"DouyinGuajiGUI.exe",
"web_gui.exe",
"run_cli.exe",
"_internal/base_library.zip",
"_internal/python312.dll",
"assets/fudai.png",
"webui/index.html",
"config/README.md",
"logs/.keep",
"pic/.keep",
"state/.keep",
]
issues = find_distribution_issues(entries)
assert "platform-tools/adb.exe" in issues
assert "platform-tools/AdbWinApi.dll" in issues
assert "platform-tools/AdbWinUsbApi.dll" in issues
def test_distribution_manifest_cli_passes_clean_tree(tmp_path):
dist = tmp_path / "dist"
for rel in [
@@ -154,6 +208,9 @@ def test_distribution_manifest_cli_passes_clean_tree(tmp_path):
"webui/css/base.css",
"webui/js/api_client.js",
"webui/index.html",
"platform-tools/adb.exe",
"platform-tools/AdbWinApi.dll",
"platform-tools/AdbWinUsbApi.dll",
"config/README.md",
"logs/.keep",
"pic/.keep",
+6
View File
@@ -267,3 +267,9 @@ def test_windows_packaging_script_protects_core_modules_by_default():
assert "Join-Path $BuildSourceRoot \"gui\\gui_dashboard_app_entry.py\"" in script
assert "Join-Path $BuildSourceRoot \"gui\\web_gui_entry.py\"" in script
assert "Join-Path $BuildSourceRoot \"bin\\run_cli_entry.py\"" in script
assert '[string]$PlatformToolsDir = ""' in script
assert '"ANDROID_PLATFORM_TOOLS", "ANDROID_HOME", "ANDROID_SDK_ROOT"' in script
assert '$PlatformToolFiles = @(' in script
assert '"adb.exe"' in script
assert '"AdbWinApi.dll"' in script
assert '"AdbWinUsbApi.dll"' in script
+5
View File
@@ -119,6 +119,11 @@ class TestSpecificPaths:
os.path.join(PROJECT_ROOT, "run_cli.exe")
]
def test_bundled_adb_path_uses_project_root(self):
assert path_config.get_bundled_adb_path() == os.path.join(
PROJECT_ROOT, "platform-tools", "adb.exe"
)
# ============================================================
# 路径间不应互相重复
+12
View File
@@ -27,6 +27,10 @@ class TestAdbPath:
def test_default_returns_adb(self, monkeypatch):
# 默认走 ADB_EXECUTABLE 环境变量;如果未设,应返回 'adb'
monkeypatch.delenv("ADB_EXECUTABLE", raising=False)
monkeypatch.setattr(
"douyin.core.underlying_operations_pkg.adb_helpers.path_config.find_bundled_adb",
lambda: None,
)
assert _adb_path() == "adb"
def test_env_override(self, monkeypatch):
@@ -38,6 +42,14 @@ class TestAdbPath:
# 包了引号的应当去引号返回 raw 路径
assert _adb_path() == "C:\\Program Files\\adb.exe"
def test_uses_bundled_adb_when_env_missing(self, monkeypatch):
monkeypatch.delenv("ADB_EXECUTABLE", raising=False)
monkeypatch.setattr(
"douyin.core.underlying_operations_pkg.adb_helpers.path_config.find_bundled_adb",
lambda: r"C:\App\platform-tools\adb.exe",
)
assert _adb_path() == r"C:\App\platform-tools\adb.exe"
class TestAdbArgs:
def test_basic(self):