test_build_batch_launch: read the batch's exit code after it has exited (TEST-BATCH-LAUNCH-EXITCODE) #1002
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1002
Loading…
Reference in a new issue
No description provided.
Delete branch "batch-launch-exitcode"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: TEST-BATCH-LAUNCH-EXITCODE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137887651)
What and why
tests/test_build_batch_launch.pyfails on this Windows 10 PC: the helper startscmd.exewith-PassThru, takes$p.Handleand reads$p.ExitCodeafterWaitForExit(). The stub batch has already exited by then, so ExitCode is usually null (28 of 30 runs) andexit $p.ExitCodeturns it into 0.The helper now uses
-Wait -PassThru. A null code is reported as 999, which no case expects. The parsed production-ArgumentListexpression, 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
-Waitadds time to each start.Tested
Windows 10 Pro 22H2 (19045), Windows PowerShell 5.1, CPython 3.12.10:
Ran 2 tests ... FAILED (failures=3)compileall,test_text_write_line_endings,check_no_game_data.py: cleanGPUs 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
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator rule)🤖 Generated with Claude Code
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:build_llvm_mc.ps1(WaitForExit)build_llvm_mc.ps1(WaitForExit)build_runtime.ps1(HasExitedloop)build_runtime.ps1(HasExitedloop)A failed build can't read as success there:
$null -ne 0is true in PowerShell, so a null code throwsbuild 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 withexit $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
-ArgumentListexpression from the scripts.AI-assisted (Claude Code, Claude Opus 5.5).
Native Windows 11 + PowerShell 5.1 Verification (
cb878ea034) — PASSDiff-audited
tests/test_build_batch_launch.py(+5/-3) and executed on native Windows 11 (10.0.26200, Windows PowerShell5.1, Python3.12.10with-I).Results
Start-ProcessExit-Code Stress Runs:test_build_batch_launch.pyskips on non-Windows hosts, executed 3 consecutive full runs ofpython -I tests/test_build_batch_launch.pymerged ontoorigin/main(829530dbd0):Ran 2 tests in 53.538s — OKRan 2 tests in 56.314s — OKRan 2 tests in 54.744s — OKStart-Process cmd.exe -ArgumentList '/c exit 7' -NoNewWindow -Wait -PassThru):40/40runs returned exactExitCode == 7(0null/mismatched exit codes), and theif ($null -eq $p.ExitCode) { exit 999 }guard guarantees any nullExitCodefails loudly instead of coercingexit $nullto0.tests/test_ci_registration.py(18/18),tests/test_text_write_line_endings.py(3/3), andscripts/check_no_game_data.pyall pass (rc=0).AI-assisted.
RUN of #1002 (
python -I, no build, no game, no GPU)Heads tested: PR head
cb878ea0345e, current main829530dbd019; merged = main + PR head,git merge --no-ff, local only (merged cleanly).Commands, one process each, from the worktree root:
python -I tests/test_build_batch_launch.py, repeated (it starts PowerShell and cmd.exe, so it is timing dependent)Related:
tests/test_text_write_line_endings.py,tests/test_ci_registration.py,python -I -m compileall -q tests/test_build_batch_launch.py. Only the test file changes; the build scripts are untouched.ExitCoderead from a child that has already exited) seen on Windows 10. Main's version of the test passed 22 of 22 runs here: 10 one after the other (about 10 s each) and 12 at the same time (one burst of about 32 s). So there is no red to show on Windows 11; the PR is a flakiness fix and this run neither confirms nor refutes the 28-of-30 figure.test_text_write_line_endings.pyandtest_ci_registration.pypass; compileall exits 0.-Wait.scripts/build_llvm_mc.ps1andscripts/build_runtime.ps1still readExitCodeafterWaitForExit()/ aHasExitedloop, which the test no longer copies.Machine: Windows 11 Pro 10.0.26300, CPython 3.13.12, GPU not used.
Merged after enlight3d's red/green check (check) (RTX 3090, driver 621.40, Windows 11) and a local re-check here. Merged after local re-verification: this PR merged onto
main0f2025b16 without conflict, and its test file(s) (tests/test_build_batch_launch.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.