tooling: read the localized Write-Warning prefix in startup_run_ps1 #2263

Merged
alvaroolt merged 2 commits from upstream-pr/2271 into main 2026-11-25 10:13:41 +00:00
alvaroolt commented 2026-11-25 09:04:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by alvaroolt on 2026-11-25T09:04:11Z.


Change

tests/startup_run_ps1_check.py (ctest startup_run_ps1) expects the -FakeUser warning that #2167 added to tools/startup/run.ps1 as WARNING: Without -FakeUser, user API calls go to the host gaming runtime (docs/startup-runtime.md). PowerShell localizes the Write-Warning prefix with the host's UI language. On Spanish Windows it prints ADVERTENCIA: ..., so every case without -FakeUser fails, although run.ps1 behaves as intended:

FAIL powershell: stub exit 2: printed ['ADVERTENCIA: Without -FakeUser, user API calls go to the host gaming runtime (docs/startup-runtime.md).', 'stub debugger line 1', ...], expected ['WARNING: Without -FakeUser, ...', 'stub debugger line 1', ...]
...
startup run.ps1 exit code: 5 failed (executed with powershell)

Because main() skips the mutants once the real script fails, none of the mutant controls ran on such a host either.

The check now reads the prefix from each shell under test. It runs Write-Warning '<probe text>' with -NoProfile -Command in the same environment as run.ps1 (including NO_COLOR=1). The output must be exactly one line that ends with the probe text after a non-empty prefix, or the check stops with a diagnostic. The warning line is still compared exactly, as <prefix><message>. A new mutant replaces Write-Warning with Write-Host for the same text. The run must still reject it, which shows that the prefix is checked and not just stripped. run.ps1 is unchanged. No issue.

Related: #2167 added the warning and its expected line. #2217 made the same comparison independent of ANSI colors with NO_COLOR=1, which the probe also uses. Neither covers a localized prefix.

Verification

Environment: Windows 11 10.0.26300.9974 (UI language es-ES), Windows PowerShell 5.1.26100.9818 (pwsh not installed), Python 3.12 (out/pe-env), MSVC 14.52, Windows SDK 10.0.26100. Commit 766f83e2 on upstream main 1a713de0.

python -B tests/startup_run_ps1_check.py              # before: 5 failed (above); after: 0 failed (executed with powershell), exit 0
python -B tests/startup_run_ps1_check.py --text-only  # 0 failed (text only: requested), exit 0
ctest --preset dev --no-tests=error -R '^startup_run_ps1$' -V   # passed

Controls, run from a scratch script against the changed module:

  • Probed prefix on this host: 'ADVERTENCIA: '.
  • Real run.ps1 with the prefix forced to the old 'WARNING: ': 1 problem per case. This is the failure on main.
  • Write-Host mutant with the probed prefix: rejected (printed ['Without -FakeUser, ...', ...]).
  • Write-Host mutant with the prefix forced to '': no problem reported. Without the prefix comparison, the mutant would pass.

On 766f83e2:

python -B tools/run_checks_parallel.py <the 108 checks of the python-linux job>   # 107 ok, 1 failed

Full suite on the previous base 28e5f4d6 plus the same test change (NVIDIA GeForce RTX 5080, AMD Radeon iGPU, WARP; debug layer unavailable). The rebase brought no change to tests/startup_run_ps1_check.py or tools/startup/run.ps1.

ctest --preset release --no-tests=error -j 4   # 1532 tests: 1493 passed, 1 failed, 38 capability skips

The failure in both runs is rdna2_tools_check, because this host has no llvm-mc on PATH. With LLVM_LIB, LLVM_MC (LLVM 15.0.7) and LLVM_OBJCOPY set, it passes: Ran 156 tests ... OK (skipped=1). This change does not touch it. The dev suite on 28e5f4d6 without this change gave the same 1532 tests and 38 skips. Its only failures were startup_run_ps1 and the same rdna2_tools_check.

Evidence and follow-up

Not measured: an English host, where the probe should return WARNING: and the check should behave as before (the Windows CI job covers this), and pwsh, which is not installed here. It takes the same probe path.

Observed once, unrelated to the prefix: in one run_checks_parallel.py run on 766f83e2, the -Translate case with debugger exit 7 failed with run.ps1 exited 1. The stderr was a NativeCommandError from taskkill.exe /T /F on line 79 ("ERROR: el proceso con PID … (proceso secundario de PID …)"). With $ErrorActionPreference = "Stop", Windows PowerShell 5.1 turns the redirected stderr of a native command into a terminating error. The check then passed in 8 of 8 serial runs, in 8 of 8 runs started at once, and in a second full run_checks_parallel.py run. This PR does not change that line.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed (none changed).
  • I did not include game files, dumps, distribution links or secrets.

This change was AI-assisted (Claude Code); I reviewed the diff and the test results.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6600923134 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2271). Originally posted by [alvaroolt](https://github.com/alvaroolt) on 2026-11-25T09:04:11Z. --- ## Change `tests/startup_run_ps1_check.py` (ctest `startup_run_ps1`) expects the `-FakeUser` warning that #2167 added to `tools/startup/run.ps1` as `WARNING: Without -FakeUser, user API calls go to the host gaming runtime (docs/startup-runtime.md).` PowerShell localizes the `Write-Warning` prefix with the host's UI language. On Spanish Windows it prints `ADVERTENCIA: ...`, so every case without `-FakeUser` fails, although `run.ps1` behaves as intended: ``` FAIL powershell: stub exit 2: printed ['ADVERTENCIA: Without -FakeUser, user API calls go to the host gaming runtime (docs/startup-runtime.md).', 'stub debugger line 1', ...], expected ['WARNING: Without -FakeUser, ...', 'stub debugger line 1', ...] ... startup run.ps1 exit code: 5 failed (executed with powershell) ``` Because `main()` skips the mutants once the real script fails, none of the mutant controls ran on such a host either. The check now reads the prefix from each shell under test. It runs `Write-Warning '<probe text>'` with `-NoProfile -Command` in the same environment as `run.ps1` (including `NO_COLOR=1`). The output must be exactly one line that ends with the probe text after a non-empty prefix, or the check stops with a diagnostic. The warning line is still compared exactly, as `<prefix><message>`. A new mutant replaces `Write-Warning` with `Write-Host` for the same text. The run must still reject it, which shows that the prefix is checked and not just stripped. `run.ps1` is unchanged. No issue. Related: #2167 added the warning and its expected line. #2217 made the same comparison independent of ANSI colors with `NO_COLOR=1`, which the probe also uses. Neither covers a localized prefix. ## Verification Environment: Windows 11 10.0.26300.9974 (UI language es-ES), Windows PowerShell 5.1.26100.9818 (`pwsh` not installed), Python 3.12 (`out/pe-env`), MSVC 14.52, Windows SDK 10.0.26100. Commit 766f83e2 on upstream `main` 1a713de0. ```powershell python -B tests/startup_run_ps1_check.py # before: 5 failed (above); after: 0 failed (executed with powershell), exit 0 python -B tests/startup_run_ps1_check.py --text-only # 0 failed (text only: requested), exit 0 ctest --preset dev --no-tests=error -R '^startup_run_ps1$' -V # passed ``` Controls, run from a scratch script against the changed module: - Probed prefix on this host: `'ADVERTENCIA: '`. - Real `run.ps1` with the prefix forced to the old `'WARNING: '`: 1 problem per case. This is the failure on `main`. - `Write-Host` mutant with the probed prefix: rejected (`printed ['Without -FakeUser, ...', ...]`). - `Write-Host` mutant with the prefix forced to `''`: no problem reported. Without the prefix comparison, the mutant would pass. On 766f83e2: ```powershell python -B tools/run_checks_parallel.py <the 108 checks of the python-linux job> # 107 ok, 1 failed ``` Full suite on the previous base 28e5f4d6 plus the same test change (NVIDIA GeForce RTX 5080, AMD Radeon iGPU, WARP; debug layer unavailable). The rebase brought no change to `tests/startup_run_ps1_check.py` or `tools/startup/run.ps1`. ```powershell ctest --preset release --no-tests=error -j 4 # 1532 tests: 1493 passed, 1 failed, 38 capability skips ``` The failure in both runs is `rdna2_tools_check`, because this host has no `llvm-mc` on `PATH`. With `LLVM_LIB`, `LLVM_MC` (LLVM 15.0.7) and `LLVM_OBJCOPY` set, it passes: `Ran 156 tests ... OK (skipped=1)`. This change does not touch it. The `dev` suite on 28e5f4d6 without this change gave the same 1532 tests and 38 skips. Its only failures were `startup_run_ps1` and the same `rdna2_tools_check`. ## Evidence and follow-up Not measured: an English host, where the probe should return `WARNING: ` and the check should behave as before (the Windows CI job covers this), and `pwsh`, which is not installed here. It takes the same probe path. Observed once, unrelated to the prefix: in one `run_checks_parallel.py` run on 766f83e2, the `-Translate` case with debugger exit 7 failed with `run.ps1 exited 1`. The stderr was a `NativeCommandError` from `taskkill.exe /T /F` on line 79 ("ERROR: el proceso con PID … (proceso secundario de PID …)"). With `$ErrorActionPreference = "Stop"`, Windows PowerShell 5.1 turns the redirected stderr of a native command into a terminating error. The check then passed in 8 of 8 serial runs, in 8 of 8 runs started at once, and in a second full `run_checks_parallel.py` run. This PR does not change that line. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed (none changed). - [x] I did not include game files, dumps, distribution links or secrets. This change was AI-assisted (Claude Code); I reviewed the diff and the test results.
tedin7 commented 2026-11-25 10:05:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T09:09:52Z.

Review: COMMENTED


Review of head 766f83e2853ae3c7a3f5bf6fad03c0ce67f25e11 (test-only change to tests/startup_run_ps1_check.py).

Findings: 0 P1, 0 P2.

  • The expected warning line no longer hard-codes WARNING: . The prefix is read once per shell by running Write-Warning on a probe string, with the same environment as run.ps1, then cached. This is correct for localized hosts (for example a Spanish UI).
  • The probe fails closed: it exits if the output is not exactly one line, does not end with the probe, or has no prefix.
  • The new mutant (warning printed with Write-Host) is a real behavior regression the old test could also have missed on a non-English host. It is now rejected.
  • Scope is one test file. No concurrent open or merged PR touches the same check.

Commands executed locally:

  • python3 tests/docs_links_check.py: pass (18 files, 433 links)
  • python3 tests/bidi_controls_check.py: pass
  • git diff --check origin/main...HEAD: clean
  • python3 tests/startup_run_ps1_check.py on Linux: text-only (no PowerShell host here), exit 0
  • python3 x2w_pipe.py win2025 2271: Windows Server 2025, dev and release /O2, ctest -R '^startup_run_ps1$' 1/1 passed in both. This run executes the check's built-in mutants, including the new Write-Host one, and the test passed, so every mutant was rejected.

Notes:

  • CI Build and test on Windows: pass.
  • CI Linux jobs are red on tests/mesh_* checks only. They are not touched by this diff. The branch is 7 commits behind main.
  • I could not run a separate hand-made mutation on Linux because there is no PowerShell here. The mutation evidence is the in-test mutant set run on Windows.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6054669584 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2271#pullrequestreview-6054669584). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T09:09:52Z. **Review:** COMMENTED --- Review of head `766f83e2853ae3c7a3f5bf6fad03c0ce67f25e11` (test-only change to `tests/startup_run_ps1_check.py`). Findings: 0 P1, 0 P2. - The expected warning line no longer hard-codes `WARNING: `. The prefix is read once per shell by running `Write-Warning` on a probe string, with the same environment as `run.ps1`, then cached. This is correct for localized hosts (for example a Spanish UI). - The probe fails closed: it exits if the output is not exactly one line, does not end with the probe, or has no prefix. - The new mutant (warning printed with `Write-Host`) is a real behavior regression the old test could also have missed on a non-English host. It is now rejected. - Scope is one test file. No concurrent open or merged PR touches the same check. Commands executed locally: - `python3 tests/docs_links_check.py`: pass (18 files, 433 links) - `python3 tests/bidi_controls_check.py`: pass - `git diff --check origin/main...HEAD`: clean - `python3 tests/startup_run_ps1_check.py` on Linux: text-only (no PowerShell host here), exit 0 - `python3 x2w_pipe.py win2025 2271`: Windows Server 2025, dev and release /O2, `ctest -R '^startup_run_ps1$'` 1/1 passed in both. This run executes the check's built-in mutants, including the new Write-Host one, and the test passed, so every mutant was rejected. Notes: - CI `Build and test on Windows`: pass. - CI Linux jobs are red on `tests/mesh_*` checks only. They are not touched by this diff. The branch is 7 commits behind main. - I could not run a separate hand-made mutation on Linux because there is no PowerShell here. The mutation evidence is the in-test mutant set run on Windows. AI-assisted; commands listed were executed locally.
RavenCurseBurg commented 2026-11-25 10:05:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T09:11:23Z.


Independent Windows test of 766f83e2 on build 26100.9711 with Python 3.14.3, Windows PowerShell 5.1.26100.9711 and PowerShell 7.6.9:

python -B tests/startup_run_ps1_check.py
startup run.ps1 exit code: 0 failed (executed with powershell, pwsh)
python -B tests/startup_run_ps1_check.py --text-only
startup run.ps1 exit code: 0 failed (text only: requested)

Both shells emitted WARNING: under their default settings. I exercised the new Write-Host mutation directly with each shell. Both rejected it at the output-line comparison.

I also selected zh-CN for the current thread in the Windows PowerShell 5.1 probe and the scratch copy of the launcher, using [Threading.Thread]::CurrentThread.CurrentUICulture = [Globalization.CultureInfo]::GetCultureInfo('zh-CN'). The real shell emitted 警告: (UTF-8 bytes e8 ad a6 e5 91 8a 3a 20). With that prefix, the real warning passed the exit-2 case and the Write-Host mutation failed the line comparison. This culture override was limited to those test processes.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7157994148 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2271#issuecomment-7157994148). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T09:11:23Z. --- Independent Windows test of `766f83e2` on build 26100.9711 with Python 3.14.3, Windows PowerShell 5.1.26100.9711 and PowerShell 7.6.9: ```text python -B tests/startup_run_ps1_check.py startup run.ps1 exit code: 0 failed (executed with powershell, pwsh) python -B tests/startup_run_ps1_check.py --text-only startup run.ps1 exit code: 0 failed (text only: requested) ``` Both shells emitted `WARNING: ` under their default settings. I exercised the new `Write-Host` mutation directly with each shell. Both rejected it at the output-line comparison. I also selected `zh-CN` for the current thread in the Windows PowerShell 5.1 probe and the scratch copy of the launcher, using `[Threading.Thread]::CurrentThread.CurrentUICulture = [Globalization.CultureInfo]::GetCultureInfo('zh-CN')`. The real shell emitted `警告: ` (UTF-8 bytes `e8 ad a6 e5 91 8a 3a 20`). With that prefix, the real warning passed the exit-2 case and the `Write-Host` mutation failed the line comparison. This culture override was limited to those test processes.
upstream-sync closed this pull request 2026-11-25 11:02:14 +00:00
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!2263
No description provided.