Private
Public Access
0
0

fix(test): drop rmtree race in live_gui workspace creation

The session-scoped live_gui fixture deleted the shared workspace
before recreating it, which raced with the per-worker lock acquisition
and produced FileNotFoundError on .live_gui_owner.lock in xdist.
The per-run timestamped name (tests/artifacts/live_gui_workspace_<ts>/)
already provides enough isolation between pytest invocations, so the
rmtree is unnecessary. Use mkdir(exist_ok=True) only.
This commit is contained in:
2026-06-09 23:31:09 -04:00
parent 283bb7085b
commit 33d02bb11f
+9 -10
View File
@@ -475,20 +475,19 @@ def live_gui(request) -> Generator["_LiveGuiHandle", None, None]:
gui_script = os.path.abspath("sloppy.py")
diag = VerificationLogger("live_gui_startup", "live_gui_diag")
diag.log_state("GUI Script", "N/A", "gui_2.py")
# 1. Create the run workspace (one per pytest invocation, shared by the
# single owner worker that actually runs live_gui tests).
# Per-run isolation: each `uv run pytest` gets a fresh timestamped folder.
# Per-test pollution is INTENTIONAL (exposes fragility, per the
# workspace_path_finalize_20260609 spec).
# NOTE: do NOT rmtree the workspace here. With xdist, 16 workers share this
# path concurrently; an rmtree-by-any-worker would delete the dir between
# another worker's mkdir and lock acquisition, causing FileNotFoundError.
# The timestamp-based name provides enough isolation for normal use; if you
# re-run within the same second, just wait a second.
temp_workspace = _RUN_WORKSPACE
if temp_workspace.exists():
for _ in range(5):
try:
shutil.rmtree(temp_workspace)
break
except OSError:
time.sleep(0.5)
# Create the workspace directory before writing files
temp_workspace.mkdir(parents=True, exist_ok=True)
# Create minimal project files to avoid cluttering root
(temp_workspace / "manual_slop.toml").write_text("[project]\nname = 'TestProject'\n\n[conductor]\ndir = 'conductor'\n", encoding="utf-8")
(temp_workspace / "conductor" / "tracks").mkdir(parents=True, exist_ok=True)