Skip to content

fix(tests): forward Windows home variables through the hermetic test runner#71112

Open
Sanjays2402 wants to merge 1 commit into
NousResearch:mainfrom
Sanjays2402:fix/70813-windows-hermetic-test-runner
Open

fix(tests): forward Windows home variables through the hermetic test runner#71112
Sanjays2402 wants to merge 1 commit into
NousResearch:mainfrom
Sanjays2402:fix/70813-windows-hermetic-test-runner

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

What does this PR do?

scripts/run_tests.sh runs the suite under env -i so no credential variable can leak into tests. It forwards HOME, which is enough on POSIX, but native Windows CPython resolves Path.home() from USERPROFILE (or HOMEDRIVE + HOMEPATH), and other platform directories come from LOCALAPPDATA/APPDATA. With those stripped, collection can fail on native Windows for any test that touches Path.home().

This forwards those five location variables through the hermetic boundary, and pins PYTHONIOENCODING=utf-8 so 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

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • scripts/run_tests.sh: build a WIN_ENV array from USERPROFILE, HOMEDRIVE, HOMEPATH, LOCALAPPDATA, APPDATA (only when set) and expand it into the exec env -i argument list; add PYTHONIOENCODING=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

  1. .venv/bin/python -m pytest tests/scripts/test_run_tests_sh_env.py -q → 13 passed.
  2. Revert scripts/run_tests.sh and rerun → 8 failed, 5 passed (RED verified on unpatched main; the 5 that still pass are the credential-scrubbing assertions, which must not regress).
  3. bash -n scripts/run_tests.sh → clean.
  4. On POSIX, USERPROFILE/LOCALAPPDATA/APPDATA are unset, so the env -i line is unchanged.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've added tests for my changes
  • I've tested on my platform: macOS 26.5 (Apple Silicon)

Documentation & Housekeeping

  • I've updated relevant documentation — N/A (no user-facing config or docs surface changes)
  • I've updated cli-config.yaml.example — N/A
  • I've updated CONTRIBUTING.md / AGENTS.md — N/A
  • I've considered cross-platform impact — this is the cross-platform fix; POSIX behavior is unchanged because the variables are only forwarded when set

@alt-glitch alt-glitch added type/test Test coverage or test infrastructure P3 Low — cosmetic, nice to have platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows labels Jul 25, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: this fixes #70813 and overlaps the native-Windows hermetic-runner approaches in #67387 and #67512; maintainers should select the preferred scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: hermetic Windows test runner drops home variables and decodes pytest output with the legacy code page

2 participants