fix: resume CBB batches after verified native release

This commit is contained in:
阿白叔 committed 2026-11-25 09:28:05 +08:00
1 parent c76b755f13
commit 5bab125122
18 files changed
+642 -60

No files matched your search

+73
View File
@@ -111,6 +111,79 @@ def test_smoke_arguments_exit_zero_and_write_lifecycle_log(tmp_path: Path):
assert "gui_smoke_window_created" in text
def test_desktop_duplicate_activates_original_and_recovers_after_exit(tmp_path):
import os
import subprocess
import sys
import time
harness = r'''
import os, sys
from PySide6.QtWidgets import QWidget
from cbb_refresh_verify import application
from cbb_refresh_verify.ui import main_window
class Window(QWidget):
def __init__(self, *, logging_context):
super().__init__()
self.directory = logging_context.root
def show(self):
self.showMinimized()
(self.directory / f'{os.getpid()}.started').touch()
def activateWindow(self):
assert not self.isMinimized()
(self.directory / f'{os.getpid()}.activated').touch()
super().activateWindow()
main_window.MainWindow = Window
raise SystemExit(application.main(sys.argv[1:]))
'''
data = tmp_path / 'data'
independent = tmp_path / 'other'
processes = []
def start(directory):
process = subprocess.Popen([sys.executable, '-c', harness, '--data-root', str(directory)],
env={**os.environ, 'QT_QPA_PLATFORM': 'offscreen'})
processes.append(process)
return process
def wait_for_file(path):
deadline = time.monotonic() + 12
while not path.exists() and time.monotonic() < deadline:
time.sleep(.03)
assert path.is_file(), path
try:
initial = start(data)
wait_for_file(data / f'{initial.pid}.started')
duplicate = start(data / '..' / data.name.upper())
assert duplicate.wait(timeout=8) == 0
assert {path.stem for path in data.glob('*.started')} == {str(initial.pid)}
assert (data / f'{initial.pid}.activated').is_file()
other = start(independent)
wait_for_file(independent / f'{other.pid}.started')
initial.kill()
initial.wait(timeout=5)
contenders = [start(data), start(data)]
deadline = time.monotonic() + 12
while not any(process.poll() is not None for process in contenders) and time.monotonic() < deadline:
time.sleep(.03)
assert sorted((process.poll() for process in contenders), key=lambda value: value is None) == [0, None]
surviving = next(process for process in contenders if process.poll() is None)
assert {path.stem for path in data.glob('*.started')} == {str(initial.pid), str(surviving.pid)}
assert (data / f'{surviving.pid}.activated').is_file()
finally:
for process in processes:
if process.poll() is None:
process.kill()
process.wait(timeout=5)
def test_module_entrypoint_propagates_main_exit_code():
import subprocess, sys
code = (