tests: decode startup staging diagnostics safely on Windows #2591

Merged
R0Y00 merged 2 commits from upstream-pr/2599 into main 2026-11-26 03:21:38 +00:00
R0Y00 commented 2026-11-25 22:40:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T22:40:20Z.


Follow-up to #1549. On a Windows host with active ANSI code page 936, PowerShell 7 writes UTF-8 diagnostics. Python’s default text-mode capture raised UnicodeDecodeError in its pipe-reader thread and the staging guard then received None instead of stderr. Decode the PowerShell diagnostics explicitly as UTF-8 with replacement and keep the system decoding with replacement for cmd.exe’s junction diagnostic. The fixture still asserts exit status, ASCII diagnostic markers, output contents and path guards as before.

At b41f6fca the first command below reproduced the decoder error. On 81c0fda3 both passed on Windows 11 build 26200 with Python 3.12 and locale.getpreferredencoding(False) == 'cp936':

python -X utf8=0 -B tests/startup_stage_package_check.py pwsh
python -X utf8=0 -B tests/startup_stage_package_check.py powershell.exe

The fixture uses synthetic files and keeps the missing/empty input, junction, overwrite and package-preservation checks. This changes the test harness only.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6615220289 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2599). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T22:40:20Z. --- Follow-up to #1549. On a Windows host with active ANSI code page 936, PowerShell 7 writes UTF-8 diagnostics. Python’s default text-mode capture raised `UnicodeDecodeError` in its pipe-reader thread and the staging guard then received `None` instead of stderr. Decode the PowerShell diagnostics explicitly as UTF-8 with replacement and keep the system decoding with replacement for `cmd.exe`’s junction diagnostic. The fixture still asserts exit status, ASCII diagnostic markers, output contents and path guards as before. At `b41f6fca` the first command below reproduced the decoder error. On `81c0fda3` both passed on Windows 11 build 26200 with Python 3.12 and `locale.getpreferredencoding(False) == 'cp936'`: ```powershell python -X utf8=0 -B tests/startup_stage_package_check.py pwsh python -X utf8=0 -B tests/startup_stage_package_check.py powershell.exe ``` The fixture uses synthetic files and keeps the missing/empty input, junction, overwrite and package-preservation checks. This changes the test harness only.
tedin7 commented 2026-11-26 03:19:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:19:06Z.

Review: COMMENTED


Review of 19dce04b (after gh pr update-branch; the PR's own diff is unchanged from 81c0fda3).

Scope: test harness only, tests/startup_stage_package_check.py (+4/-3). Both PowerShell captures and the mklink /J capture now decode explicitly (encoding="utf-8", errors="replace" for PowerShell, system decoding with errors="replace" for cmd.exe). All existing assertions are untouched.

Checked:

  • The change matches the described cause: text=True used the locale code page and raised in the reader thread, so stderr came back None. Explicit decoding with replacement removes that failure mode.
  • No production code touched. Nothing else in the file captures text output.
  • git diff --check origin/main...HEAD: clean. python3 tests/docs_links_check.py: 19 files, 498 links ok. python3 tests/bidi_controls_check.py: ok.
  • Win2025 (Build 26100), ctest --preset dev -R '^startup_stage_package$': 1/1 passed on 19dce04b.

Limits: the Win2025 host does not use code page 936, so this run does not reproduce the original decode error. That evidence is the author's python -X utf8=0 run on cp936 in the PR body. I did not mutate the test (it needs PowerShell; the Linux host has none).

No blocking findings.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068103495 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2599#pullrequestreview-6068103495). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:19:06Z. **Review:** COMMENTED --- Review of `19dce04b` (after `gh pr update-branch`; the PR's own diff is unchanged from `81c0fda3`). Scope: test harness only, `tests/startup_stage_package_check.py` (+4/-3). Both PowerShell captures and the `mklink /J` capture now decode explicitly (`encoding="utf-8", errors="replace"` for PowerShell, system decoding with `errors="replace"` for `cmd.exe`). All existing assertions are untouched. Checked: - The change matches the described cause: `text=True` used the locale code page and raised in the reader thread, so `stderr` came back `None`. Explicit decoding with replacement removes that failure mode. - No production code touched. Nothing else in the file captures text output. - `git diff --check origin/main...HEAD`: clean. `python3 tests/docs_links_check.py`: 19 files, 498 links ok. `python3 tests/bidi_controls_check.py`: ok. - Win2025 (Build 26100), `ctest --preset dev -R '^startup_stage_package$'`: 1/1 passed on `19dce04b`. Limits: the Win2025 host does not use code page 936, so this run does not reproduce the original decode error. That evidence is the author's `python -X utf8=0` run on cp936 in the PR body. I did not mutate the test (it needs PowerShell; the Linux host has none). No blocking findings. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-26 04:04:10 +00:00
tedin7 commented 2026-11-26 04:04:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:19:18Z.


Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 19dce04be3a6b8619848ecac33de584c753c48d7:

  • Debug (--preset dev): ctest --preset dev -R '^startup_stage_package$' --parallel 2 --no-tests=error --output-on-failure: 1/1 passed (5.97s).
  • Python-only change (test harness): no build output changes, so no release build was run.

Command: python3 x2w_pipe.py win2025 2599 --regex '^startup_stage_package$' --wait 7200

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7181607303 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2599#issuecomment-7181607303). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:19:18Z. --- Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `19dce04be3a6b8619848ecac33de584c753c48d7`: - **Debug (`--preset dev`)**: `ctest --preset dev -R '^startup_stage_package$' --parallel 2 --no-tests=error --output-on-failure`: **1/1 passed** (`5.97s`). - Python-only change (test harness): no build output changes, so no release build was run. Command: `python3 x2w_pipe.py win2025 2599 --regex '^startup_stage_package$' --wait 7200` AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 04:04:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:21:09Z.


[PASS] PR #2599@19dce04b ready-to-post snippet (NOT posted):

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 19dce04be3a6b8619848ecac33de584c753c48d7:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev -- -j 2): 0.00s (configure 0.00s)
    • Test (ctest --preset dev -R '^startup_stage_package$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (6.34s: startup_stage_package 6.10s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release -- -j 2): 0.00s (configure 0.00s)
    • Test (ctest --preset release -R '^startup_stage_package$' --parallel 2 --no-tests=error --output-on-failure): 1/1 passed (6.62s: startup_stage_package 6.31s)
  • sccache: 1/7 hits; wall 31.3s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7181639104 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2599#issuecomment-7181639104). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:21:09Z. --- [PASS] PR #2599@19dce04b ready-to-post snippet (NOT posted): Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `19dce04be3a6b8619848ecac33de584c753c48d7`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev -- -j 2`): `0.00s` (configure `0.00s`) - Test (`ctest --preset dev -R '^startup_stage_package$' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`6.34s`: `startup_stage_package` `6.10s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release -- -j 2`): `0.00s` (configure `0.00s`) - Test (`ctest --preset release -R '^startup_stage_package$' --parallel 2 --no-tests=error --output-on-failure`): **1/1 passed** (`6.62s`: `startup_stage_package` `6.31s`) - `sccache`: 1/7 hits; wall `31.3s` AI-assisted; commands listed were executed locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2591
No description provided.