Skip to content

tests: a test that spawns bash/sh must check the platform (#7312, #7619) - #7695

Merged
squid-protocol merged 1 commit into
mainfrom
ci/windows-bash-guard
Nov 4, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
ci/windows-bash-guard

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

What

New gate, tests/test_shell_tests_platform_guard.py. Any tracked test file that runs bash, sh or a .sh script through subprocess must check the platform somewhere in the file. Spawns are found with an AST scan: run / Popen / call / check_call / check_output whose command is a shell literal, a "bash -c ..." string, a .sh path, or a name bound to shutil.which("bash"). The check can be sys.platform, os.name or platform.system(), as a skipif, a pytest.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:

Red-main issue Culprit Fixed by What happened on Windows
#7312 #7171 test_full_suite_control.py #7314 bash is the WSL launcher and drops the env the step reads
#7619 #7577 / #7608 test_infeasible_outcomes.py solver filter #7620 shutil.which("bash") finds WSL, so the is None skip never fired; CRLF kept a \r

A which-is-None skip is not enough for that reason. The gate asks for a platform check instead.

Proof that it can fail

  • On the two files as they were before their fixes, CI: full-suite negative control; a blind CodeQL scan fails (Part of #7155) #7171's merge commit and tests: solver-check filter test is Linux-only (#7619) #7620's parent, the gate reports test_full_suite_control.py:25 and test_infeasible_outcomes.py:346.
  • On main today it passes. Seven test files spawn a shell (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.
  • The pinned cases are both red-main shapes, the #7620-style fix passing, a string command, a .sh script, and a language-name list that is not a spawn.

Cost

A text pre-filter, subprocess plus 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

Windows-only failure shape Covered
bash/sh spawned with no platform check this PR
Text-mode write read back by bash (CRLF) caught indirectly: such a file spawns bash, so it must check the platform
Path separators or os.sep assumptions in pure-Python tests not covered. No red-main issue in the window. A cheap Windows leg chosen by path would cover it; out of scope here (.claude/rules/ci-workflows.md load 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

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]>
@squid-protocol
squid-protocol merged commit 67a3e27 into main Nov 4, 2026
32 checks passed
@squid-protocol
squid-protocol deleted the ci/windows-bash-guard branch November 4, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant