fix(tests): forward Windows home variables through the hermetic test runner#71112
Open
Sanjays2402 wants to merge 1 commit into
Open
fix(tests): forward Windows home variables through the hermetic test runner#71112Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
Collaborator
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 does this PR do?
scripts/run_tests.shruns the suite underenv -iso no credential variable can leak into tests. It forwardsHOME, which is enough on POSIX, but native Windows CPython resolvesPath.home()fromUSERPROFILE(orHOMEDRIVE+HOMEPATH), and other platform directories come fromLOCALAPPDATA/APPDATA. With those stripped, collection can fail on native Windows for any test that touchesPath.home().This forwards those five location variables through the hermetic boundary, and pins
PYTHONIOENCODING=utf-8so child pytest output decodes consistently on CP936/CP932 hosts.The credential allowlist is unchanged. These are location variables, not secrets, and each one is forwarded only when it is actually set, so a POSIX run produces the exact same environment it did before.
Related Issue
Fixes #70813
Type of Change
Changes Made
scripts/run_tests.sh: build aWIN_ENVarray fromUSERPROFILE,HOMEDRIVE,HOMEPATH,LOCALAPPDATA,APPDATA(only when set) and expand it into theexec env -iargument list; addPYTHONIOENCODING=utf-8.tests/scripts/test_run_tests_sh_env.py: new guard covering the forwarded variables, the set-only behavior, the UTF-8 pin, and that credential variables are still absent from the allowlist.How to Test
.venv/bin/python -m pytest tests/scripts/test_run_tests_sh_env.py -q→ 13 passed.scripts/run_tests.shand rerun → 8 failed, 5 passed (RED verified on unpatched main; the 5 that still pass are the credential-scrubbing assertions, which must not regress).bash -n scripts/run_tests.sh→ clean.USERPROFILE/LOCALAPPDATA/APPDATAare unset, so theenv -iline is unchanged.Checklist
Code
Documentation & Housekeeping
cli-config.yaml.example— N/ACONTRIBUTING.md/AGENTS.md— N/A