test(tools): make subprocess env regressions Windows-portable
The PYTHONPATH/PATH sanitization suite was written POSIX-centric and failed on real Windows 11 (reproduced natively: 4 failures before this change). Fix the tests to express the true per-platform contract: - test_other_major_version_site_packages_preserved / test_make_run_env_injects_hermes_bin_dir: build inputs with os.pathsep instead of hardcoded ':'. - test_make_run_env_appends_homebrew_on_minimal_path: split on os.pathsep, neutralise Git Bash dir prepending, and assert the documented Windows passthrough (_append_missing_sane_path_entries is a no-op off POSIX) instead of the Homebrew append. - test_make_run_env_real_launchd_path_gains_homebrew: mark macos_only per repo OS-marker policy (the regression is the macOS launchd PATH; the merge is a passthrough on Windows). - test_configured_home_alias_matches_launcher_output: create the configured-home link via a helper that falls back to an unprivileged directory junction (cmd /c mklink /J) when symlink creation raises WinError 1314, and skips with a clear reason if no mechanism exists. Also correct a stale comment in execute_code: the child is not always the same Python as Hermes (project mode can select an external venv), so the strip is about compatibility, not redundancy.
This commit is contained in:
@@ -1486,10 +1486,10 @@ def execute_code(
|
||||
#
|
||||
# Before re-injecting PYTHONPATH, strip Hermes-owned entries that
|
||||
# leaked through _scrub_child_env (PYTHONPATH is in _SAFE_ENV_PREFIXES
|
||||
# so it passes the scrub). The sandbox runs the SAME Python as
|
||||
# Hermes, so the Hermes venv entries are redundant — and if they
|
||||
# came from a different Hermes venv they would poison the sandbox's
|
||||
# sys.path with ABI-incompatible C extensions (#74817).
|
||||
# so it passes the scrub). They are redundant for same-Hermes-
|
||||
# environment children and may be incompatible with external
|
||||
# interpreters (project mode can select a different venv), so they
|
||||
# must not shadow or poison the child's sys.path (#74817).
|
||||
from tools.environments.local import _strip_hermes_owned_pythonpath
|
||||
_strip_hermes_owned_pythonpath(child_env)
|
||||
_hermes_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
Reference in New Issue
Block a user