test_make_game_argparse: the --jobs 10 case no longer needs 10 hardware threads #1

Manually merged
github merged 1 commit from gh-pr/1/head into gh-pr/1/base 2026-11-26 08:39:34 +00:00
Owner

@⁠Rareuncommon on GitHub · 2026-11-24 00:32 UTC · original
Rareuncommon:test/jobs-clamp-cpu-count → main · +2 −1 · 1 files · 1 commits · merged 2026-11-24 02:27 UTC

Claimed in the coordination issue as: not claimed. This repository has no coordination issue yet; on the original one I had posted it as a finding: shortly before that repository went away.

What and why

tests/test_make_game_argparse.py JobsHandlingTest.test_custom_jobs_forwarded_to_assets fails on any machine with fewer than 10 hardware threads.

make_game.main() clamps --jobs to the machine's hardware threads (leonida_tui.clamp_jobs), so the test's --jobs 10 reaches assets() as the thread count and the assertion fails:

Expected: assets(<game>, <work>, True, 10, dump_jobs=None)
  Actual: assets(<game>, <work>, True, 6, dump_jobs=None)

The tool is right; the test depends on the machine that runs it. This pins os.cpu_count to 16 inside that one test, so 10 is in range anywhere. One file changed, two lines added and one removed; no tool code is touched.

Tested

macOS arm64 (6 hardware threads), Python 3.14.6, CPU only, no game files:

  • python -I tests/test_make_game_argparse.py: 1 failure in 38 tests on main 8eee35cfd; no failures with this change (38 run, 1 skipped).
  • python -m compileall -q make_game.py tools tests: pass.
  • python -I make_game.py --help: pass.
  • python -I scripts/check_no_game_data.py tests/test_make_game_argparse.py: pass.

Not run: Linux, Windows, any GPU test, the translator suite (no translator code changes). I have not checked a machine with 10 or more threads, where the test already passed before this change.

AI-assisted: yes (Claude Code).

Checklist

  • 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. (Not applicable: no translator change.)

🤖 Generated with Claude Code

**@⁠Rareuncommon** on GitHub · 2026-11-24 00:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1) `Rareuncommon:test/jobs-clamp-cpu-count` → `main` · +2 −1 · 1 files · 1 commits · merged 2026-11-24 02:27 UTC Claimed in the coordination issue as: not claimed. This repository has no coordination issue yet; on the original one I had posted it as a `finding:` shortly before that repository went away. ### What and why `tests/test_make_game_argparse.py` `JobsHandlingTest.test_custom_jobs_forwarded_to_assets` fails on any machine with fewer than 10 hardware threads. `make_game.main()` clamps `--jobs` to the machine's hardware threads (`leonida_tui.clamp_jobs`), so the test's `--jobs 10` reaches `assets()` as the thread count and the assertion fails: ``` Expected: assets(<game>, <work>, True, 10, dump_jobs=None) Actual: assets(<game>, <work>, True, 6, dump_jobs=None) ``` The tool is right; the test depends on the machine that runs it. This pins `os.cpu_count` to 16 inside that one test, so 10 is in range anywhere. One file changed, two lines added and one removed; no tool code is touched. ### Tested macOS arm64 (6 hardware threads), Python 3.14.6, CPU only, no game files: - `python -I tests/test_make_game_argparse.py`: 1 failure in 38 tests on `main` `8eee35cfd`; no failures with this change (38 run, 1 skipped). - `python -m compileall -q make_game.py tools tests`: pass. - `python -I make_game.py --help`: pass. - `python -I scripts/check_no_game_data.py tests/test_make_game_argparse.py`: pass. Not run: Linux, Windows, any GPU test, the translator suite (no translator code changes). I have not checked a machine with 10 or more threads, where the test already passed before this change. AI-assisted: yes (Claude Code). ### Checklist - [x] 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. (Not applicable: no translator change.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
main() clamps --jobs to the machine's hardware threads (leonida_tui.clamp_jobs, since #1797), so on a machine
with fewer than 10 the test's --jobs 10 reached assets() as the thread count and the assertion failed. The
test pins os.cpu_count to 16, so 10 is in range anywhere.

AI-assisted (Claude Code). Tested on macOS arm64 (6 hardware threads), Python 3.14.6: tests/test_make_game_argparse.py
fails 1 of 38 on main de4c37383 and passes with this change; compileall and make_game.py --help pass.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:39:33 +00:00
github manually merged commit 63c5ece18c into gh-pr/1/base 2026-11-26 08:39:34 +00:00
Author
Owner

@⁠wavehs on GitHub · 2026-11-24 01:11 UTC · original

macOS arm64 verification (Apple M3 Pro, 12 hardware threads) — the failure reproduces exactly, and the fix is the right one

PR head 63c5ece18, one commit, test-only: tests/test_make_game_argparse.py +2/−1. Base in this repository is main e33f4cef; the branch is five commits behind it, so I checked the merge as well as the change.

Check Result
git merge-tree --write-tree ubi/main 63c5ece18 clean (no conflicts despite the stale base)
tests/test_make_game_argparse.py on main, 6 CPUs 1 of 38 fails — test_custom_jobs_forwarded_to_assets
same at the PR head, 6 CPUs 38/38 pass (1 skip)
same at the PR head, 12 CPUs 38/38 pass
python -I scripts/run_semantic_tests.py tests/semantic, main 459 files, 6,046 tests, 2 files failed
same at the PR head identical — 459 / 6,046 / 2

The two red files in both suite runs are test_exec_computed and test_image_atomics_guard, both already red on main here and unrelated to a test-only change. Nothing in this PR touches a shader, the translator or the runtime, so there are no GPU fixtures to run; I did not run any.

How I reproduced it, because the obvious way does not work. This machine has 12 threads, and the test passes at 12, so I lowered the count with PYTHON_CPU_COUNT=6 — which is ignored under -I, since -I implies -E:

PYTHON_CPU_COUNT=6 python3 -I -c 'import os; print(os.cpu_count())'   -> 12
PYTHON_CPU_COUNT=6 python3    -c 'import os; print(os.cpu_count())'   -> 6

So the reproduction is PYTHON_CPU_COUNT=6 python3 tests/test_make_game_argparse.py, and there it matches your report one-for-one: mock_assets.assert_called_once_with(..., 10, ...) versus the clamped 6. Worth knowing for anyone else who tries to verify this on a big machine, since the file's docstring (like the rest of the repository) says to run it with -I.

The fix is correct. Pinning os.cpu_count to 16 puts 10 inside cpu1_jobs_bounds's (1, cpus // 2, cpus), so clamp_jobs(10) returns 10 on any host, and the assertion keeps testing what it is named after — that --jobs 10 is forwarded — instead of testing the machine. patch("make_game.leonida_tui.os.cpu_count", ...) does reach the real os module (leonida_tui does import os), so the patch is effective.

Two notes, neither blocking.

  • The same file already patches the count at line 344 as with patch("os.cpu_count", return_value=cpus):; your line spells it make_game.leonida_tui.os.cpu_count. Same object, two styles in one file — using the existing one keeps the next reader from wondering whether they differ.
  • I swept the whole family at 6 CPUs to see whether this machine dependence exists anywhere else: all 22 tests/test_make_game_*.py pass except test_make_game_platform, which fails 3 tests on unmodified main too. That one is the macOS /var → /private/var symlink: the test builds paths from tempfile and make_game.runtime resolves the output directory (make_game.py:2205, os.path.realpath(out)), so /var/folders/… becomes /private/var/folders/… and the JSON comparison fails (14 mentions of private/var in the failure output). Not yours, but if you are collecting macOS test drift it is the next one.

No game files. AI-assisted.

**@⁠wavehs** on GitHub · 2026-11-24 01:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1#issuecomment-7118850466) **macOS arm64 verification (Apple M3 Pro, 12 hardware threads) — the failure reproduces exactly, and the fix is the right one** PR head `63c5ece18`, one commit, test-only: `tests/test_make_game_argparse.py` +2/−1. Base in this repository is `main` `e33f4cef`; the branch is five commits behind it, so I checked the merge as well as the change. | Check | Result | |---|---| | `git merge-tree --write-tree ubi/main 63c5ece18` | **clean** (no conflicts despite the stale base) | | `tests/test_make_game_argparse.py` on `main`, 6 CPUs | **1 of 38 fails** — `test_custom_jobs_forwarded_to_assets` | | same at the PR head, 6 CPUs | **38/38 pass** (1 skip) | | same at the PR head, 12 CPUs | 38/38 pass | | `python -I scripts/run_semantic_tests.py tests/semantic`, `main` | 459 files, 6,046 tests, **2 files failed** | | same at the PR head | **identical** — 459 / 6,046 / 2 | The two red files in both suite runs are `test_exec_computed` and `test_image_atomics_guard`, both already red on `main` here and unrelated to a test-only change. Nothing in this PR touches a shader, the translator or the runtime, so there are no GPU fixtures to run; I did not run any. **How I reproduced it, because the obvious way does not work.** This machine has 12 threads, and the test passes at 12, so I lowered the count with `PYTHON_CPU_COUNT=6` — which is ignored under `-I`, since `-I` implies `-E`: ``` PYTHON_CPU_COUNT=6 python3 -I -c 'import os; print(os.cpu_count())' -> 12 PYTHON_CPU_COUNT=6 python3 -c 'import os; print(os.cpu_count())' -> 6 ``` So the reproduction is `PYTHON_CPU_COUNT=6 python3 tests/test_make_game_argparse.py`, and there it matches your report one-for-one: `mock_assets.assert_called_once_with(..., 10, ...)` versus the clamped `6`. Worth knowing for anyone else who tries to verify this on a big machine, since the file's docstring (like the rest of the repository) says to run it with `-I`. **The fix is correct.** Pinning `os.cpu_count` to 16 puts 10 inside `cpu1_jobs_bounds`'s `(1, cpus // 2, cpus)`, so `clamp_jobs(10)` returns 10 on any host, and the assertion keeps testing what it is named after — that `--jobs 10` is forwarded — instead of testing the machine. `patch("make_game.leonida_tui.os.cpu_count", ...)` does reach the real `os` module (`leonida_tui` does `import os`), so the patch is effective. **Two notes, neither blocking.** - The same file already patches the count at line 344 as `with patch("os.cpu_count", return_value=cpus):`; your line spells it `make_game.leonida_tui.os.cpu_count`. Same object, two styles in one file — using the existing one keeps the next reader from wondering whether they differ. - I swept the whole family at 6 CPUs to see whether this machine dependence exists anywhere else: all 22 `tests/test_make_game_*.py` pass except `test_make_game_platform`, which fails 3 tests on unmodified `main` too. That one is the macOS `/var` → `/private/var` symlink: the test builds paths from `tempfile` and `make_game.runtime` resolves the output directory (`make_game.py:2205`, `os.path.realpath(out)`), so `/var/folders/…` becomes `/private/var/folders/…` and the JSON comparison fails (14 mentions of `private/var` in the failure output). Not yours, but if you are collecting macOS test drift it is the next one. No game files. AI-assisted.
Author
Owner

@⁠wavehs on GitHub · 2026-11-24 02:24 UTC · original

The Windows check job on 9ec34cdff (run 45306800350, job 138157329747) fails two cases in this file, not one; this patch covers test_custom_jobs_forwarded_to_assets:

FAIL: test_custom_jobs_forwarded_to_shaders
AssertionError: expected call not found.
Expected: preflight(['shaders'], '...\\work', False, None, emulate=True, keep_emulated=True, fallbacks=(), jobs=6)
Actual:   preflight(['shaders'], '...\\work', False, None, emulate=True, keep_emulated=True, fallbacks=(), jobs=4)

test_custom_jobs_forwarded_to_shaders asks for --jobs 6, which main() clamps to the runner's 4 hardware threads. The same one-line fix (patch make_game.leonida_tui.os.cpu_count) applied there as well would close both; I have not touched the file.

For reference I did the same for tests/test_make_game_pipelines.py in #83, where --jobs 5 reached the checker as 4.

**@⁠wavehs** on GitHub · 2026-11-24 02:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1#issuecomment-7120100907) The Windows `check` job on `9ec34cdff` (run 45306800350, job 138157329747) fails two cases in this file, not one; this patch covers `test_custom_jobs_forwarded_to_assets`: ``` FAIL: test_custom_jobs_forwarded_to_shaders AssertionError: expected call not found. Expected: preflight(['shaders'], '...\\work', False, None, emulate=True, keep_emulated=True, fallbacks=(), jobs=6) Actual: preflight(['shaders'], '...\\work', False, None, emulate=True, keep_emulated=True, fallbacks=(), jobs=4) ``` `test_custom_jobs_forwarded_to_shaders` asks for `--jobs 6`, which `main()` clamps to the runner's 4 hardware threads. The same one-line fix (patch `make_game.leonida_tui.os.cpu_count`) applied there as well would close both; I have not touched the file. For reference I did the same for `tests/test_make_game_pipelines.py` in #83, where `--jobs 5` reached the checker as 4.
This discussion has been locked. Commenting is limited to contributors.
No description provided.