fix(dsh): slim packaged runtime and surface startup errors
This commit is contained in:
1 parent
df250e04ba
commit
caa79e7fcf
7 files changed
+159
-5
No files matched your search
@@ -0,0 +1,40 @@
|
||||
from pathlib import Path
|
||||
import importlib.util
|
||||
|
||||
_MODULE = Path(__file__).resolve().parents[2] / 'packaging' / 'dsh_runtime_staging.py'
|
||||
_SPEC = importlib.util.spec_from_file_location('dsh_runtime_staging', _MODULE)
|
||||
_LOADED = importlib.util.module_from_spec(_SPEC)
|
||||
assert _SPEC and _SPEC.loader
|
||||
_SPEC.loader.exec_module(_LOADED)
|
||||
stage_node_modules = _LOADED.stage_node_modules
|
||||
|
||||
|
||||
def _package(root: Path, name: str, *, os=None, cpu=None, files=()):
|
||||
path = root / name
|
||||
path.mkdir(parents=True)
|
||||
manifest = {'name': name, 'version': '1.0.0'}
|
||||
if os is not None:
|
||||
manifest['os'] = os
|
||||
if cpu is not None:
|
||||
manifest['cpu'] = cpu
|
||||
import json
|
||||
(path / 'package.json').write_text(json.dumps(manifest), encoding='utf8')
|
||||
for relative, content in files:
|
||||
target = path / relative
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text(content, encoding='utf8')
|
||||
|
||||
|
||||
def test_stage_dsh_runtime_keeps_windows_runtime_and_prunes_other_platforms(tmp_path):
|
||||
source = tmp_path / 'node_modules'
|
||||
(source / '@deepseek-ai' / 'dsh').mkdir(parents=True)
|
||||
(source / '@deepseek-ai' / 'dsh' / 'package.json').write_text('{}', encoding='utf8')
|
||||
_package(source, 'win-addon', os=['win32'], cpu=['x64'], files=[('index.js', 'ok')])
|
||||
_package(source, 'linux-addon', os=['linux'], files=[('index.js', 'drop')])
|
||||
_package(source, 'docs-only', files=[('index.js', 'ok'), ('README.md', 'drop'), ('source.ts', 'drop')])
|
||||
staged = stage_node_modules(source, tmp_path / 'staged')
|
||||
assert (staged / 'win-addon' / 'index.js').read_text(encoding='utf8') == 'ok'
|
||||
assert not (staged / 'linux-addon').exists()
|
||||
assert (staged / 'docs-only' / 'index.js').is_file()
|
||||
assert not (staged / 'docs-only' / 'README.md').exists()
|
||||
assert not (staged / 'docs-only' / 'source.ts').exists()
|
||||
@@ -58,6 +58,15 @@ def test_direct_navigation_opens_harness_and_returns_without_losing_task(ui, mon
|
||||
assert window._dsh_view.starts == 1
|
||||
|
||||
|
||||
def test_dsh_navigation_surfaces_lazy_startup_failure(ui, monkeypatch, qtbot):
|
||||
window = ui.window
|
||||
def fail(_self):
|
||||
raise RuntimeError('controlled missing WebEngine')
|
||||
monkeypatch.setattr(type(window), '_create_dsh_view', fail)
|
||||
qtbot.mouseClick(window.dsh_navigation, Qt.MouseButton.LeftButton)
|
||||
assert 'DSH助手启动失败' in window.run_panel.operator_band.text()
|
||||
|
||||
|
||||
def test_cross_task_harness_action_never_reaches_task_service(ui, monkeypatch):
|
||||
window = ui.window
|
||||
monkeypatch.setattr(type(window), '_create_dsh_view', lambda self: HarnessView(self), raising=False)
|
||||
|
||||
Reference in new issue
Block a user