fix: tolerate transient continuation read locks and record regression results

This commit is contained in:
阿白叔 committed 2026-10-15 16:44:33 +08:00
1 parent b47059587a
commit e655797e32
5 files changed
+111 -3

No files matched your search

+7 -1
View File
@@ -22,7 +22,13 @@ while True:
(root/'project-session-result.tsv').write_text(f'{session}\\t{job}\\tsaved_ok\\tsession_verified',encoding='utf-8')
with (root/'steps.txt').open('a') as f:f.write(job+'\\n')
while not (root/'project-session-next.tsv').exists():time.sleep(.005)
token,job=(root/'project-session-next.tsv').read_text().split('\\t')
# Match the real VBS continuation reader's bounded sharing-denial retry.
for attempt in range(20):
try:
token,job=(root/'project-session-next.tsv').read_text().split('\\t')
break
except (PermissionError,FileNotFoundError):time.sleep(.05)
else:raise RuntimeError('control read remained unavailable')
(root/'project-session-next.tsv').unlink()
if token!=session:sys.exit(8)
if job=='close':break
+43
View File
@@ -0,0 +1,43 @@
from pathlib import Path
import re
import subprocess
from threading import Timer
def test_real_vbs_continuation_read_waits_out_windows_sharing_denial(tmp_path):
import win32file
import win32con
source = (Path(__file__).resolve().parents[2] / 'integration/dxdesigner795/QuickPartReplace.vbs').read_text(encoding='utf-8')
functions = []
for name in ('QPReadUtf8', 'QPReadContinuation'):
match = re.search(r'^Function ' + name + r'\(.*?^End Function', source, re.M | re.S)
assert match, name
functions.append(match.group())
script = tmp_path / 'read_control.vbs'
script.write_text('\n'.join(functions) + '\nWScript.Echo "reading"\nWScript.Echo QPReadContinuation(WScript.Arguments(0))\n')
control = tmp_path / 'control.tsv'
control.write_text('token\tjob')
held = win32file.CreateFile(str(control), win32con.GENERIC_READ, 0, None, win32con.OPEN_EXISTING, 0, None)
released = False
def release():
nonlocal released
if not released:
released = True
held.Close()
process = subprocess.Popen((r'C:\Windows\SysWOW64\cscript.exe', '//nologo', str(script), str(control)),
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
timer = None
try:
assert process.stdout.readline().strip() == 'reading'
timer = Timer(.2, release)
timer.start()
stdout, stderr = process.communicate(timeout=5)
assert process.returncode == 0, stderr
assert stdout.strip() == 'token\tjob'
finally:
if timer:
timer.join()
release()
if process.poll() is None:
process.kill()
process.wait()