fix(tests): use the platform temp dir for the isolation-probe handoff - #74083
fix(tests): use the platform temp dir for the isolation-probe handoff#74083hyqqx wants to merge 1 commit into
Conversation
Native Windows 11 verification (monerostar)Could not leave a formal Approve (fork collaborator scope) — posting review-as-comment with live evidence. Verified on a live Windows 11 Pro host. The Host evidence
|
|
Thanks for the focused Windows collection fix. Current The PR moves the first import into the POSIX-only execution path and replaces the second fallback with Automated hermes-sweeper review. |
tests/test_run_tests_parallel.py builds its handoff directory from
`os.environ.get("TMPDIR", "/tmp")` and mkdir()s it at module scope. On
Windows TMPDIR is normally unset -- the platform uses TEMP/TMP -- so the
fallback resolves to a non-existent \tmp on the current drive and raises
during collection:
tests\test_run_tests_parallel.py:38: in <module>
_HANDOFF_DIR.mkdir(exist_ok=True)
E FileNotFoundError: [WinError 3] The system cannot find the path
specified: '\tmp\hermes-isolation-probe'
pytest aborts the whole run on a collection error, so this one line stops
the entire suite on native Windows.
The module already declares the right intent -- its docstring says
"POSIX-only ... Marked accordingly" and the probe carries
`@pytest.mark.skipif(sys.platform == "win32", reason="POSIX-only probe")`.
The marker never gets a chance to apply, because the mkdir runs at import
time.
`tempfile.gettempdir()` is the cross-platform primitive for this, and it
still honours $TMPDIR first, so POSIX behaviour is byte-identical. Nothing
else changes: `_HANDOFF_DIR` is read only by `_handoff_path_for`, whose
sole caller is the skipped POSIX probe.
Verified on native Windows 11 (build 26200), Python 3.11.6, from a
PowerShell prompt where TMPDIR is unset:
before: Interrupted: 1 error during collection, no tests collected
after: 7 tests collected, exit 0
Note for reviewers running Git Bash: MSYS sets TMPDIR, which masks this
failure entirely -- it only reproduces from PowerShell or cmd.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
381a6b8 to
2350f21
Compare
|
Rebased onto current The Rebase done. The head was ~600 commits behind; it is now one commit on top of What remains is still broken on With this commit: Worth restating @monerostar's observation, since it explains why this survived so long: Git Bash sets |
tneemo
left a comment
There was a problem hiding this comment.
Independent verification — #74083 (Windows: fix collection abort from /tmp fallback)
Verified the PR head (2350f21b, 1 file) on a real Windows checkout.
The bug is real and reproduced: tests/test_run_tests_parallel.py builds its handoff dir from os.environ.get("TMPDIR", "/tmp") and mkdir()s it at module scope. On native Windows (PowerShell) TMPDIR is unset, so the fallback resolves to a non-existent \tmp on the current drive → FileNotFoundError at import time, before the skipif(win32) marker can apply → pytest aborts collection for the entire suite (~50k tests). The PR description's traceback is accurate.
Verification results:
- ✅ Head fetched; parses clean (386 lines)
- ✅
tempfile.gettempdir()replaces the/tmpfallback;_HANDOFF_DIR.mkdirstill at module scope but now targets the real platform temp dir - ✅ Reproduced the critical case on this box: with
TMPDIR/TMP/TEMPall removed (pure PowerShell scenario),tempfile.gettempdir()→C:\Users\tneemo\AppData\Local\Tempand the module imports cleanly — collection no longer aborts - ✅ Module tests: 5 passed, 1 skipped; the 1 failure (
test_file_retry_self_heals_and_prints_both_attempts) is a pre-existing Windows subprocess/PATH issue that fails identically on main without the PR (verified by checkout) — not a regression - ✅ POSIX behavior unchanged:
gettempdir()honorsTMPDIRfirst, so Linux/macOS runs behave as before
Design notes:
- Correct diagnosis: the marker can't help when the crash is at import time — moving to a cross-platform primitive is the right fix, not more skip markers
- One-line change, zero behavior drift on POSIX
Verdict: Ready to land. Real Windows blocker (entire test suite uncollectable from PowerShell), minimal fix, verified on the actual failure mode.
This was generated by AI, Review is declarative
What does this PR do?
tests/test_run_tests_parallel.pybuilds its handoff directory fromos.environ.get("TMPDIR", "/tmp")andmkdir()s it at module scope. On WindowsTMPDIRis normally unset — the platform usesTEMP/TMP— so the fallback resolves to anon-existent
\tmpon the current drive and raises during collection:pytest aborts the whole run on a collection error, so this single line stops the entire
suite on native Windows.
The module already declares the right intent
Its docstring says "POSIX-only … Marked accordingly" and the probe carries
@pytest.mark.skipif(sys.platform == "win32", reason="POSIX-only probe"). The marker nevergets a chance to apply, because the
mkdirruns at import time — before pytest evaluatesany marker.
tempfile.gettempdir()is the cross-platform primitive for this, and it still honours$TMPDIRfirst, so POSIX behaviour is byte-identical. Nothing else changes:_HANDOFF_DIRis read only by
_handoff_path_for, whose sole caller is the skipped POSIX probe.Scope change since the first review
This PR originally carried two collection-time fixes. The
import ptyhalf landedindependently on
mainas05504bd9f(test(gateway): make test_gateway collectable onWindows, @iso2kx, 2026-07-30) while this was open — same approach, same call site. That
half is dropped here and the branch is rebased onto current
main, addressing@monerostar's note that the head was ~600 commits behind. What remains is the one blocker
still live on
maintoday.How to test
From PowerShell or cmd (not Git Bash — MSYS sets
TMPDIR, which masks this entirely):Before, on current
main(710b02663):After:
Running the file:
3 passed, 1 skipped, 3 failed. The three failures are pre-existingWindows gaps in the runner itself (
No test files to runfromscripts/run_tests_parallel.py) — none of them reference_HANDOFF_DIRor_handoff_path_for, and before this change they could not run at all.Platforms tested
Native Windows 11 Home, build 26200 · Python 3.11.6 · PowerShell (
TMPDIRunset).No production code is touched; on POSIX
gettempdir()returns$TMPDIRexactly as the oldexpression did.
Why CI never caught this
All CI jobs run on
ubuntu-latest(the only other runner in the tree isubuntu-24.04-arm, indocker.yml). There is no Windows runner, and Git Bash — the shellmost Windows contributors reach for — sets
TMPDIRand hides the failure.Related
05504bd9f— landed theimport ptyhalf of the original diff.tests/tools/test_search_hidden_dirs.py).