Repository navigation
tests: a test that spawns bash/sh must check the platform (#7312, #7619) - #7695
Merged
Merged
Conversation
On a Windows runner bash is the WSL launcher (shutil.which finds it; it drops the step's env and keeps CRLF's \r). #7171 and the solver-check filter test ran a workflow's bash step through subprocess, passed ubuntu-only PR CI, and turned the Full Suite Gate red on main. An AST gate now requires a sys.platform / os.name / platform.system() check in any tracked test file that spawns bash, sh or a .sh script. Flags both pre-fix files; passes the 7 files that spawn a shell today. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
New gate,
tests/test_shell_tests_platform_guard.py. Any tracked test file that runs bash, sh or a.shscript throughsubprocessmust check the platform somewhere in the file. Spawns are found with an AST scan:run/Popen/call/check_call/check_outputwhose command is a shell literal, a"bash -c ..."string, a.shpath, or a name bound toshutil.which("bash"). The check can besys.platform,os.nameorplatform.system(), as askipif, apytest.skip, or a Windows branch.Why
Two of the red-main issues from Oct 31 to Nov 4 were the same shape. A test ran a workflow's bash step through
subprocess. It passed PR CI, which is ubuntu only, then failed the Full Suite Gate's Windows legs on main:test_full_suite_control.pybashis the WSL launcher and drops the env the step readstest_infeasible_outcomes.pysolver filtershutil.which("bash")finds WSL, so theis Noneskip never fired; CRLF kept a\rA
which-is-None skip is not enough for that reason. The gate asks for a platform check instead.Proof that it can fail
test_full_suite_control.py:25andtest_infeasible_outcomes.py:346.test_box_tools,test_cancelled_gates,test_ci_retry,test_det_sweep_plan,test_full_suite_control,test_infeasible_outcomes,test_referee_panel_workflow), and all seven already check the platform.#7620-style fix passing, a string command, a.shscript, and a language-name list that is not a spawn.Cost
A text pre-filter,
subprocessplus a quoted shell name or.sh, parses 65 of about 1,460 tracked test files. That's 1.3 s locally, well under the 15 s per-test ratchet even on a 2x slower runner. My first version parsed every file that said "sh" (338 files, 4.4 s), so I tightened the filter.Class / Sibling gaps
os.sepassumptions in pure-Python tests.claude/rules/ci-workflows.mdload rules)This is item 4 of the red-main review. The sibling PRs: #7694 (py3.11 syntax floor) and the pre-merge recheck (to follow).
Checks
pytest tests/test_shell_tests_platform_guard.py: 3 passed.pr_gates.py --only xray derived lint secrets: 4/4 pass (lint with CI's ruff 0.17.2).🤖 Generated with Claude Code