Import DxPartReplace 1.2.0-beta.31 and Windows x64 dependencies
This commit is contained in:
1 parent
12895e9868
commit
427095212b
154 files changed
+8079
-267
No files matched your search
@@ -165,6 +165,39 @@ def test_two_projects_reuse_cad_and_produce_distinct_close_checkpoints(tmp_path,
|
||||
assert Cad.created[0].closed and Desktop.created[0].released
|
||||
|
||||
|
||||
def test_fingerprint_release_requires_own_read_only_matching_checkpoint(tmp_path, monkeypatch):
|
||||
import subprocess
|
||||
from dx_productivity.trial_task_center.batch_runtime import BatchCadRuntime
|
||||
from dx_productivity.trial_task_center import worker_monitor
|
||||
class ReadCad(Cad):
|
||||
def __init__(self, *args, read_only=False, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
monkeypatch.setattr(worker_monitor, 'run_monitored_process', lambda command, *a, **k:
|
||||
subprocess.CompletedProcess(command, 0, '', ''))
|
||||
command, project = command_for(tmp_path)
|
||||
runtime = BatchCadRuntime(tmp_path / 'data', 'bom_import', desktop_factory=Desktop, cad_factory=ReadCad)
|
||||
with runtime:
|
||||
runtime.run_worker(command, 5)
|
||||
assert not runtime.release_idle_for_fingerprint(project.with_name('other.prj'))
|
||||
assert not Cad.created[-1].closed
|
||||
assert runtime.release_idle_for_fingerprint(project)
|
||||
assert Cad.created[-1].closed and Desktop.created[-1].released
|
||||
assert runtime.cad is None and runtime.desktop is None
|
||||
runtime.run_worker(command, 5)
|
||||
assert runtime.generation == 2
|
||||
|
||||
|
||||
def test_fingerprint_release_does_not_terminate_write_sessions(tmp_path, monkeypatch):
|
||||
import subprocess
|
||||
command, project = command_for(tmp_path)
|
||||
runtime = worker_runtime(tmp_path, monkeypatch, lambda command, *a, **k:
|
||||
subprocess.CompletedProcess(command, 0, '', ''))
|
||||
with runtime:
|
||||
runtime.run_worker(command, 5)
|
||||
assert not runtime.release_idle_for_fingerprint(project)
|
||||
assert not Cad.created[-1].closed
|
||||
|
||||
|
||||
@pytest.mark.parametrize('second_fails', [False, True])
|
||||
def test_prewrite_failure_releases_old_desktop_and_retries_only_once(tmp_path, monkeypatch, second_fails):
|
||||
import subprocess
|
||||
@@ -347,7 +380,7 @@ def test_native_rebuild_requires_strict_source_and_worker_proof(tmp_path):
|
||||
for path in (project, database)}}
|
||||
path = evidence / 'native-retry-proof.json'
|
||||
path.write_text(json.dumps(proof))
|
||||
with BatchCadRuntime(tmp_path / 'data', 'bom_import', desktop_factory=Desktop) as runtime:
|
||||
with BatchCadRuntime(tmp_path / 'data', 'execution', desktop_factory=Desktop) as runtime:
|
||||
with runtime.native_scope(evidence) as scope:
|
||||
pass
|
||||
proof['binding'] = scope.identity
|
||||
@@ -497,6 +530,7 @@ def test_restart_reconciles_only_confirmed_disappearance_without_replacement(tmp
|
||||
class Api:
|
||||
def confirm_desktop_released(self, name):
|
||||
assert name == runtime.record['desktop']
|
||||
self.desktop_release_check = {'released': not present[0]}
|
||||
if present[0]:
|
||||
raise OSError('desktop still held by external thread')
|
||||
monkeypatch.setattr(isolated_desktop, '_Win32Api', Api)
|
||||
@@ -606,3 +640,22 @@ def test_attempts_live_under_short_session_root(tmp_path, monkeypatch):
|
||||
runtime.run_worker(command, 5)
|
||||
assert list((runtime.path.parent / 'attempts').rglob('job.json'))
|
||||
assert not (Path(command[3]) / 'batch-attempts').exists()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('stage,expected', [('open_project', '打开工程超时'), ('inventory_sheets', '工程读取超时')])
|
||||
def test_read_timeout_is_not_reported_as_project_corruption(tmp_path, monkeypatch, stage, expected):
|
||||
import subprocess
|
||||
from dx_productivity.trial_task_center.project_discovery import ReleasedProjectReadError
|
||||
command, project = command_for(tmp_path)
|
||||
def stalled(*args, **kw):
|
||||
(Path(command[3]) / 'worker-progress.json').write_text(json.dumps({'stage': stage}))
|
||||
raise subprocess.TimeoutExpired(command, 45)
|
||||
runtime = worker_runtime(tmp_path, monkeypatch, stalled)
|
||||
runtime.cad_factory = lambda *a, read_only=False, **kw: Cad(*a, **kw)
|
||||
runtime.read_only = True
|
||||
with runtime, pytest.raises(ReleasedProjectReadError) as caught:
|
||||
runtime.run_worker(command, 150)
|
||||
assert expected in caught.value.message
|
||||
assert '工程损坏' not in caught.value.message
|
||||
assert Desktop.created[-1].released and Cad.created[-1].closed
|
||||
assert json.loads((Path(command[3]) / 'project-read-release.json').read_text())['resources_released'] is True
|
||||
Reference in new issue
Block a user