Repository navigation
test(shell): run the platform-independent shell tests on Windows - #4136
Conversation
A module-level skipif on four shell suites meant a Windows contributor saw "77 skipped" where CI saw 77 real results, and "77 skipped" reads as green. That is how a confirm-gate defect in #3808 got verified locally and still failed on ubuntu. The skip is demoted to a per-test @posix_only mark on exactly the tests that launch a process. The refusal, parsing, grant and tool-description tests never reach a shell, so they now run everywhere. Across the four modules: 112 skipped becomes 70 passed / 42 skipped on Windows, with POSIX unchanged — the mark's condition is the same sys.platform check, so it is a no-op off Windows. Membership was measured, not guessed: a probe wrapped subprocess.Popen/run and recorded which tests actually spawned. Every assertion is byte-identical. test_shell_pipelines.py keeps its module-level mark because all seven of its tests really do run a pipeline.
|
Verdict: Approve Windows contributors were seeing The split holds up under review: every test left unmarked asserts a refusal or a parse result, and every test asserting successful execution or real output carries the mark. Off Windows the mark is a no-op, so nothing changes for the existing CI lanes. No assertions were weakened or removed — the only deletions are the three old mark names. One thing to keep in mind rather than fix: nothing enforces the split going forward. A future test in these files that launches a process but forgets the mark will only surface once the Windows lane from #4127 exists. That lane is the right guard, so this is a note, not a request. Real-world evidenceN/A — tests-only change; no runnable product surface, so no evidence bundle was produced and the verdict rests on static review plus the counts in the PR description. The description does carry the relevant proof: real Windows 11 runs before and after ( 🔍 Technical detailsVerification performed Parsed all three modules and cross-checked mark membership against what each test asserts. Every one of the 29 unmarked tests asserts Could not run the suites here — pytest is not installed in this environment — so the POSIX no-op claim rests on the mark's condition being byte-identical to the one it replaced, which it is in all three files. Points checked and cleared
🟢 Nit — the split has no automated guard ( Membership is a judgement recorded as 35 decorators. The PR's own measurement method (wrapping Strengths
|
Why this matters
A Windows contributor running the four shell test suites sees
112 skipped, which is visually indistinguishable from green. CI on ubuntu and macOS sees 112 real results. So the loop is: verify locally, see no red, push, watch CI fail — which is exactly how the confirm-gate defect in #3808 reached CI undetected.The skip reason is genuine for the tests that actually launch a process: Windows runs each pipeline through
cmd.exe, andos.killpg/ process groups are POSIX-only. It is not genuine for the refusal, parsing, grant and tool-description tests — those decide before anything reaches a shell, and a module-level skip was hiding them on the platform most GAIA contributors develop on. After this change Windows runs 70 passed / 42 skipped instead of112 skipped, and every one of those 70 is a real assertion about the security-adjacent refusal path.POSIX is untouched: the per-test mark carries the same
sys.platform == "win32"condition the module-level one did, so off Windows it is a no-op and all 112 still run.🔍 Technical details
Membership was measured, not guessed. A throwaway pytest plugin stripped the
cmd.exeskipifs, wrappedshell_tools.subprocess.Popen/.run, and recorded which node IDs actually spawned a child. 42 did; 70 did not. The 70 were then run on Windows 11 and all passed; every one of the 10 failures fell inside the 42. So the split is empirical, not a reading of the test names.That measurement mattered, because running the tests would have given the wrong answer. This dev box has MSYS coreutils on
PATH, sols,cat,sortanddateresolve and most execution tests pass here — they would not on a clean Windows machine or awindows-latestrunner. Classifying on "does it pass on my box" is the hidden-state trap CLAUDE.md warns about; classifying on "does it spawn a process" is not.pytestmark = pytest.mark.skipif(...)→posix_only = pytest.mark.skipif(...), same reason string per module, applied as@posix_onlyto the 35 spawning tests across three files.pytestmarkname on each of the three lines.test_shell_env_assignment.py's two existingshutil.which("pytest")skipifs stack above@posix_only; pytest ORs them, so behaviour off Windows is identical.tests/unit/test_shell_pipelines.pykeeps its module-level mark — all seven of its tests genuinely run a pipeline, so there is nothing to promote.test_shell_output_encoding.pyalready used per-test marks and is untouched.test_windows_never_hands_a_compound_line_to_cmd_exe_as_one_string— a fully-mocked test about the Windows path — was itself skipped on Windows. It now runs there.Merge-conflict note for reviewers: #3721 and #3402 both touch
test_shell_compound_commands.py, neither near thepytestmarkline. Whichever lands second may need a trivial rebase.Scope
This does not close #4127. That issue asks for
windows-latestin thetest_unit.ymlmatrix, gated on #4115 and #4119 landing first so the lane starts green. This is a prerequisite for that lane being worth anything — without it, 112 of the tests the new lane would run are skipped by construction.Test plan
python -m pytest tests/unit/test_shell_compound_commands.py tests/unit/test_shell_env_assignment.py -qon Windows 11 — was77 skipped, now51 passed, 26 skipped112 skipped, now70 passed, 42 skippedpython -m pytest tests/unit/test_shell*.py tests/unit/test_powershell_command_injection.py -q—266 passed, 42 skippedpython util/lint.py --all— output byte-identical to a cleanorigin/mainworktree (both exit 1 on the same pre-existing mypy findings insrc/gaia/, none in files this PR touches)Towards #4127.