release: ship validated Mentor PDF exporter v1.0.0
This commit is contained in:
1 parent
d4928af5b6
commit
0334f2b85b
50 files changed
+3998
-219
No files matched your search
@@ -323,3 +323,42 @@ def test_callback_error_stops_owned_tree_but_not_other_process(tmp_path, monkeyp
|
||||
if other.poll() is None:
|
||||
other.kill()
|
||||
other.wait(timeout=10)
|
||||
|
||||
|
||||
def test_success_does_not_kill_background_database_flush(tmp_path,owned_process_handles):
|
||||
import subprocess
|
||||
import win32event
|
||||
marker=tmp_path/'flush-complete.txt';pid_file=tmp_path/'flush.pid'
|
||||
child=f"import time,pathlib;time.sleep(.6);pathlib.Path({str(marker)!r}).write_text('flushed')"
|
||||
parent=("import subprocess,pathlib;"
|
||||
f"p=subprocess.Popen([{sys.executable!r},'-B','-c',{child!r}],stdin=subprocess.DEVNULL,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL);"
|
||||
f"pathlib.Path({str(pid_file)!r}).write_text(str(p.pid))")
|
||||
children=[]
|
||||
def started(message):
|
||||
if 'PID=' in message:children.append(capture_child(pid_file,owned_process_handles))
|
||||
assert run_engine([sys.executable,'-B','-c',parent],tmp_path,tmp_path/'logs',threading.Event(),10,started)==0
|
||||
assert win32event.WaitForSingleObject(children[0],5000)==win32event.WAIT_OBJECT_0
|
||||
assert marker.read_text()=='flushed'
|
||||
|
||||
|
||||
def test_cancel_after_parent_success_does_not_abort_completed_native_writeback(tmp_path,monkeypatch,owned_process_handles):
|
||||
import win32event
|
||||
from mentor_pdf_export import engine
|
||||
marker=tmp_path/'flush-late-stop.txt';pid_file=tmp_path/'late-stop.pid'
|
||||
child=f"import time,pathlib;time.sleep(.6);pathlib.Path({str(marker)!r}).write_text('flushed')"
|
||||
parent=("import subprocess,pathlib;"
|
||||
f"p=subprocess.Popen([{sys.executable!r},'-B','-c',{child!r}],stdin=subprocess.DEVNULL,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL);"
|
||||
f"pathlib.Path({str(pid_file)!r}).write_text(str(p.pid))")
|
||||
children=[];parents=[];original=engine._create_job;cancel=threading.Event()
|
||||
def bind(process):
|
||||
parents.append(owned_process_handles(process.pid));return original(process)
|
||||
def started(message):
|
||||
if 'PID=' in message:
|
||||
children.append(capture_child(pid_file,owned_process_handles))
|
||||
assert win32event.WaitForSingleObject(parents[0],5000)==win32event.WAIT_OBJECT_0
|
||||
cancel.set()
|
||||
monkeypatch.setattr(engine,'_create_job',bind)
|
||||
with pytest.raises(InterruptedError):
|
||||
run_engine([sys.executable,'-B','-c',parent],tmp_path,tmp_path/'logs',cancel,10,started)
|
||||
assert win32event.WaitForSingleObject(children[0],5000)==win32event.WAIT_OBJECT_0
|
||||
assert marker.read_text()=='flushed'
|
||||
Reference in new issue
Block a user