Repository navigation
test: pin the suite interpreter on PATH for parity script subprocesses - #5361
mehdikarimi55 wants to merge 3 commits into
Conversation
The parity tests' script variants resolve python3 -> python -> py -3 through the ambient PATH. Under `uv run pytest` the venv's bin directory is first on PATH, so the scripts see the suite interpreter (with PyYAML) and CI passes. Under the direct `.venv/bin/python -m pytest` invocation that AGENTS.md prescribes, an ambient python3 without PyYAML fails every composed-template test with "PyYAML is required" (11 failures on macOS). Prepend the running interpreter's own bin directory in parity_helpers.clean_env() so both invocations behave the same; tests that install their own shim prepend afterwards and keep precedence. Delegate test_check_prerequisites_python_parity's duplicate _clean_env() to the shared helper so the fix applies there too. Fixes github#5359 AI disclosure: agent-authored commit — OpenCode running GLM 5.3 Flash (Z.ai), agent mode under human supervision by mehdikarimi55; root-cause analysis, code change, and test execution performed by the agent.
There was a problem hiding this comment.
🟡 Changes recommended
An active moderate finding remains in tests/parity_helpers.py because Windows resolver logic can select an ambient python3 instead of the suite’s virtual-environment interpreter, leaving parity subprocesses unpinned.
1 open issue
What changed in this PR
This test-only PR aligns parity-script subprocesses with the interpreter running the test suite, preventing ambient Python installations from causing composed-template tests to fail due to missing PyYAML.
Changes:
- Prepends the suite interpreter’s directory to
PATHin the shared parity environment helper. - Reuses the shared helper for check-prerequisites parity tests instead of maintaining a duplicate implementation.
- Preserves existing interpreter-shim behavior for negative PyYAML cases.
| File | Description |
|---|---|
| tests/test_check_prerequisites_python_parity.py | Delegates file-local parity environment setup to the shared environment helper. |
| tests/parity_helpers.py | Pins parity subprocess interpreter lookup to the environment containing the running test-suite interpreter. |
Review effort: Lite (auto)
Copilot review follow-up (github#5361): a Windows venv ships python.exe but no python3.exe, so putting the venv's bin directory first on PATH cannot shadow an ambient python3 — the first name the script resolvers probe (command -v python3 succeeds and wins before the python fallback is tried). clean_env() now also prepends a cached python3 shim built with the existing make_python3_path_shim() helper (shell shim plus a .cmd for PowerShell), so parity subprocesses resolve the suite interpreter on every platform. AI disclosure: agent-authored commit — OpenCode running GLM 5.3 Flash (Z.ai), agent mode under human supervision by mehdikarimi55; fix drafted in response to the Copilot review finding, verified by rerunning the affected parity suites.
There was a problem hiding this comment.
🟡 Changes recommended
A critical helper regression unconditionally starts Bash during environment setup, causing non-Bash Windows parity tests to fail before subprocess execution when Git Bash is unavailable.
1 open issue
1 resolved since last review
Review effort: Lite (auto)
Copilot review follow-up (github#5361): _bash_posix_path() shells out to bash on Windows to convert the interpreter path, and a Windows machine with Git Bash not on PATH raised FileNotFoundError from clean_env() itself, failing every parity test during environment setup — including the python and PowerShell variants that never invoke bash. Catch the OSError and fall through to the static /mnt/ form, which the existing returncode fallback already accepts; bash-invoked tests skip when bash is absent, so the converted form is only needed where it can be exec'd. AI disclosure: agent-authored commit — OpenCode running GLM 5.3 Flash (Z.ai), agent mode under human supervision by mehdikarimi55; fix for the review finding, verified locally with the parity suites and a simulated no-bash subprocess failure.
There was a problem hiding this comment.
🔵 Needs a closer look
The changes add Windows-specific command-resolution and shim behavior, but the available macOS-only evidence cannot validate PowerShell, CreateProcess, or PATHEXT behavior, so a Windows parity run is still needed.
No open issues 🎉
1 resolved since last review
Review effort: Lite (auto)
|
On the Windows parity note: this environment is macOS only, so we cannot run Windows PowerShell 5.1 or exercise CreateProcess/PATHEXT directly. What the branch provides for Windows is by construction: Disclosure: AI-assisted comment (model: GLM), reviewed and posted by mehdikarimi55. |
There was a problem hiding this comment.
🔵 Needs a closer look
The Windows-specific python3.cmd/PATH and no-Git-Bash fallback behavior could not be independently exercised in the available Linux/macOS environments, so Windows parity coverage is needed before approval.
No open issues 🎉
Review effort: Lite (auto)
|
Thanks for tracking down the failure under the documented test invocation. AI disclosure: Drafted for @mnriem by GitHub Copilot using GPT-6.1 Sol in |


Fixes #5359
Problem
Under the invocation AGENTS.md prescribes —
uv sync --extra testthen.venv/bin/python -m pytest— 11 parity tests fail on a fresh macOS checkout whose ambientpython3lacks PyYAML:Affected: 7×
tests/test_resolve_template_python_parity.py, 2×test_check_prerequisites_python_parity.py, 1×test_create_new_feature_python_parity.py, 1×test_setup_plan_python_parity.py, 1×test_setup_tasks_python_parity.py— all composed-template cases.Root cause
run()intests/parity_helpers.pydefaults toclean_env()(a copy ofos.environ), so the bash/PowerShell script variants resolvepython3 -> python -> py -3through the ambient PATH:uv run pytestprepends the venv'sbin/to PATH → scripts see the venv interpreter (with PyYAML) → pass..venv/bin/python -m pytestleaves PATH untouched → scripts find an ambientpython3without PyYAML → fail.make_python3_path_shim()'s docstring in the same file already warns about exactly this hazard ("silently regains/loses that venv's site-packages (e.g. PyYAML)").Fix
parity_helpers.clean_env()prepends the running interpreter's own bin directory to PATH — the same thinguv rundoes — so both invocations give script subprocesses the same Python the suite runs on. Tests that install their own shim (e.g. theno_yaml_python3_shimnegative cases) prepend afterwards and keep precedence, so the negative tests are unaffected.test_check_prerequisites_python_parity.pyhad a file-local_clean_env()duplicate; it now delegates to the shared helper.Test-only change; no product code touched.
Evidence
Regression evidence is the existing suite itself, run in the affected environment (macOS 15 arm64, Python 3.12.16, checkout path with a space, ambient python3 without PyYAML):
Full local suite: 14,597 passed / 15 failed before → targeted runs green after (full-suite rerun attached below in CI).
AI disclosure
Agent-authored commit and PR — OpenCode running GLM 5.3 Flash (Z.ai), agent mode under human supervision by @mehdikarimi55. The agent performed environment reproduction, root-cause analysis, the code change, and test execution; changes were reviewed by the account owner before submission.