test_build_batch_launch: read the batch's exit code after it has exited (TEST-BATCH-LAUNCH-EXITCODE) #1002

Open
github-bot wants to merge 1 commit from github-bot/gh-1002 into main AGit
Owner

@⁠Snooozs on GitHub · 2026-11-24 16:43 UTC · original
Snooozs:batch-launch-exitcode → main · +5 −3 · 1 files · 1 commits · open

Claimed in the coordination issue as: TEST-BATCH-LAUNCH-EXITCODE (#14)

What and why

tests/test_build_batch_launch.py fails on this Windows 10 PC: the helper starts cmd.exe with -PassThru, takes $p.Handle and reads $p.ExitCode after WaitForExit(). The stub batch has already exited by then, so ExitCode is usually null (28 of 30 runs) and exit $p.ExitCode turns it into 0.

The helper now uses -Wait -PassThru. A null code is reported as 999, which no case expects. The parsed production -ArgumentList expression, the folder cases and the negative control (a launch line that drops the quotes) are unchanged.

Production scripts are untouched: with their pattern and a child that lives about 2 s, ExitCode was correct in 20 of 20 runs.

Trade-off: the file takes about 56 s here instead of 20 s, because -Wait adds time to each start.

Tested

Windows 10 Pro 22H2 (19045), Windows PowerShell 5.1, CPython 3.12.10:

  • before: Ran 2 tests ... FAILED (failures=3)
  • after: OK in five runs, and once more after the rebase
  • compileall, test_text_write_line_endings, check_no_game_data.py: clean

GPUs tested: n/a

AI-assisted: yes. Claude Code (a Haiku 5.5 subagent found the cause and wrote the change, Claude Opus 5.5 reviewed it and reran the tests).

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator rule)

🤖 Generated with Claude Code

**@⁠Snooozs** on GitHub · 2026-11-24 16:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1002) `Snooozs:batch-launch-exitcode` → `main` · +5 −3 · 1 files · 1 commits · open Claimed in the coordination issue as: TEST-BATCH-LAUNCH-EXITCODE (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why `tests/test_build_batch_launch.py` fails on this Windows 10 PC: the helper starts `cmd.exe` with `-PassThru`, takes `$p.Handle` and reads `$p.ExitCode` after `WaitForExit()`. The stub batch has already exited by then, so ExitCode is usually null (28 of 30 runs) and `exit $p.ExitCode` turns it into 0. The helper now uses `-Wait -PassThru`. A null code is reported as 999, which no case expects. The parsed production `-ArgumentList` expression, the folder cases and the negative control (a launch line that drops the quotes) are unchanged. Production scripts are untouched: with their pattern and a child that lives about 2 s, ExitCode was correct in 20 of 20 runs. Trade-off: the file takes about 56 s here instead of 20 s, because `-Wait` adds time to each start. ### Tested Windows 10 Pro 22H2 (19045), Windows PowerShell 5.1, CPython 3.12.10: - before: `Ran 2 tests ... FAILED (failures=3)` - after: OK in five runs, and once more after the rebase - `compileall`, `test_text_write_line_endings`, `check_no_game_data.py`: clean GPUs tested: n/a AI-assisted: yes. Claude Code (a Haiku 5.5 subagent found the cause and wrote the change, Claude Opus 5.5 reviewed it and reran the tests). ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator rule) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The launch helper started cmd.exe with -PassThru, held $p.Handle and then
called WaitForExit(). For a stub batch that exits at once, ExitCode can be
null, and `exit $p.ExitCode` turned that into 0. A failing folder then read
as a pass. On origin/main the test failed in every run I made, with exit
code 7 reported as 0 in several folders.

The helper now starts with -Wait -PassThru, so ExitCode is read after the
process has exited, and a null code is reported as 999, which no folder
case expects. The parsed production ArgumentList expression and the folder
cases are unchanged; the negative control that drops the quotes still
fails as intended.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:32:53 +00:00
Author
Owner

@⁠fin-github on GitHub · 2026-11-24 18:00 UTC · original · reviewed

  • python -I tests/test_build_batch_launch.py on the PR: 2 tests OK (45 s).

Concern: the description says -PassThru + $p.Handle + WaitForExit() reads a null ExitCode for a child that
exits at once (28 of 30 runs). scripts/build_llvm_mc.ps1:137-140 and scripts/build_runtime.ps1:141-145 still use
that pattern. A build batch that fails immediately (cmake configure error, missing compiler) is that same fast-exit
case, so the scripts may report a failed build as exit 0. After this change the test no longer runs the scripts'
wait/exit-code lines, so it can't catch that. Suggestion: fix the scripts the same way (or check
$null -eq $p.ExitCode there), or say in the PR why the scripts are safe, and keep the test reading the exit code
the way the scripts do.

Tested on Windows 11 Pro 26200, CPython 3.14.4, MSVC from VS 18 Community, applied on main 32950551e. No GPU or game files used. AI-assisted (Claude Code).

**@⁠fin-github** on GitHub · 2026-11-24 18:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1002#pullrequestreview-6044650803) · **reviewed** - `python -I tests/test_build_batch_launch.py` on the PR: 2 tests OK (45 s). Concern: the description says `-PassThru` + `$p.Handle` + `WaitForExit()` reads a null `ExitCode` for a child that exits at once (28 of 30 runs). `scripts/build_llvm_mc.ps1:137-140` and `scripts/build_runtime.ps1:141-145` still use that pattern. A build batch that fails immediately (cmake configure error, missing compiler) is that same fast-exit case, so the scripts may report a failed build as exit 0. After this change the test no longer runs the scripts' wait/exit-code lines, so it can't catch that. Suggestion: fix the scripts the same way (or check `$null -eq $p.ExitCode` there), or say in the PR why the scripts are safe, and keep the test reading the exit code the way the scripts do. Tested on Windows 11 Pro 26200, CPython 3.14.4, MSVC from VS 18 Community, applied on main 32950551e. No GPU or game files used. AI-assisted (Claude Code).
Author
Owner

@⁠Snooozs on GitHub · 2026-11-24 20:53 UTC · original

Thanks, worth checking, so I measured the scripts' own lines (Start-Process ... -PassThru, $p.Handle, wait, if ($p.ExitCode -ne 0) { throw }) with a child that exits at once, 20 runs each, Windows 10 19045, Windows PowerShell 5.1:

form child's code null ExitCode threw
build_llvm_mc.ps1 (WaitForExit) 7 0 20 of 20
build_llvm_mc.ps1 (WaitForExit) 0 1 1 of 20
build_runtime.ps1 (HasExited loop) 7 0 20 of 20
build_runtime.ps1 (HasExited loop) 0 0 0 of 20

A failed build can't read as success there: $null -ne 0 is true in PowerShell, so a null code throws build failed (). The race can only turn an instant success into an error, and a real successful build is never that short. The test was exposed because it passed the null on with exit $p.ExitCode, which becomes 0. So I left the scripts alone and kept this to the test.

You are right that the test doesn't run the scripts' wait and check lines. It didn't before either: it has its own copy and takes only the -ArgumentList expression from the scripts.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠Snooozs** on GitHub · 2026-11-24 20:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1002#issuecomment-7144201638) Thanks, worth checking, so I measured the scripts' own lines (`Start-Process ... -PassThru`, `$p.Handle`, wait, `if ($p.ExitCode -ne 0) { throw }`) with a child that exits at once, 20 runs each, Windows 10 19045, Windows PowerShell 5.1: | form | child's code | null ExitCode | threw | |---|---|---|---| | `build_llvm_mc.ps1` (`WaitForExit`) | 7 | 0 | 20 of 20 | | `build_llvm_mc.ps1` (`WaitForExit`) | 0 | 1 | 1 of 20 | | `build_runtime.ps1` (`HasExited` loop) | 7 | 0 | 20 of 20 | | `build_runtime.ps1` (`HasExited` loop) | 0 | 0 | 0 of 20 | A failed build can't read as success there: `$null -ne 0` is true in PowerShell, so a null code throws `build failed ()`. The race can only turn an instant *success* into an error, and a real successful build is never that short. The test was exposed because it passed the null on with `exit $p.ExitCode`, which becomes 0. So I left the scripts alone and kept this to the test. You are right that the test doesn't run the scripts' wait and check lines. It didn't before either: it has its own copy and takes only the `-ArgumentList` expression from the scripts. AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1002/head:github-bot/gh-1002'
git switch 'github-bot/gh-1002'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1002'
git switch 'github-bot/gh-1002'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1002'
git switch 'github-bot/gh-1002'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1002'
git switch 'main'
git merge --squash 'github-bot/gh-1002'
git switch 'main'
git merge --ff-only 'github-bot/gh-1002'
git switch 'main'
git merge 'github-bot/gh-1002'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.