tests: the make_game --jobs tests no longer depend on the host's core count #322

Closed
github-bot wants to merge 1 commit from github-bot/gh-322 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 03:09 UTC · original
ubiquitarianism:old-pr/10056 → main · +26 −4 · 2 files · 1 commits · closed without merging

Carried over from old PR 10056 by Poussistar in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10056, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
Poussistar: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

What

Three assertions in tests/test_make_game_argparse.py and tests/test_make_game_pipelines.py compare a --jobs value that make_game.main() has already clamped to the host's CPU count (leonida_tui.clamp_jobs, make_game.py:2873). They therefore only pass on a machine with at least as many cores as the test asks for.

This is a test-side fix only: clamp_jobs and make_game.py are untouched.

Why

On main de4c37383, with os.cpu_count() patched in-process (python -I implies -E, so PYTHON_CPU_COUNT never reaches the test — the env-var shortcut does not reproduce this):

cpus test_make_game_pipelines test_make_game_argparse
2 2 failures 2 failures
3 1 failure 2 failures
4 1 failure 2 failures
8 pass 1 failure
256 pass pass

At 4 cpus:

FAIL: test_jobs_on_the_command_line_reach_the_checker
AssertionError: '2' != '5'     (tests/test_make_game_pipelines.py:59)
FAIL: test_custom_jobs_forwarded_to_shaders
mock_preflight.assert_called_once_with(..., jobs=6)  (tests/test_make_game_argparse.py:369)

4 and 3 are the sizes of the runners this repository's CI uses (ubuntu-latest has 4 cores, macos-26 is the "three cores" of ci.yml), so both Python CI legs are red on main for this reason alone.

Change

  • Each file gets a small host_independent_jobs() helper that patches leonida_tui.cpu_jobs_bounds to (1, 1, 1 << 30) — an upper bound no host reaches — around the calls that go through main().
  • The pin is an upper bound, not a realistic number like 64: the default path is clamped too, so a low pin would fail on a big machine.
  • The clamp keeps its own coverage in test_jobs_default_calculation_scenarios, which asserts the default computation directly and does not go through main().

Tested

main de4c37383 + this patch, both files, os.cpu_count() patched in-process:

cpus 2 3 4 8 16 130 256
test_make_game_argparse.py OK OK OK OK OK OK OK
test_make_game_pipelines.py OK OK OK OK OK OK OK
  • Negative control: production clamp_jobs forced to min(2, ...) — the three tests go red again at 4 cpus (2 argparse / 2 pipelines failures) and 16 cpus (3 / 3), so the pin does not make the assertions vacuous. Restored afterwards.
  • python -m compileall -q on both files, python -I make_game.py --help: clean.
  • Linux only; nothing here touches a Windows path, a GPU or a game file.

AI-assisted (Hermes Agent). No game files.

**@⁠Andretuta** on GitHub · 2026-11-24 03:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/322) `ubiquitarianism:old-pr/10056` → `main` · +26 −4 · 2 files · 1 commits · closed without merging > Carried over from **old PR 10056** by `Poussistar` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10056`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `Poussistar`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): ## What Three assertions in `tests/test_make_game_argparse.py` and `tests/test_make_game_pipelines.py` compare a `--jobs` value that `make_game.main()` has already clamped to the host's CPU count (`leonida_tui.clamp_jobs`, `make_game.py:2873`). They therefore only pass on a machine with at least as many cores as the test asks for. This is a test-side fix only: `clamp_jobs` and `make_game.py` are untouched. ## Why On `main` `de4c37383`, with `os.cpu_count()` patched in-process (`python -I` implies `-E`, so `PYTHON_CPU_COUNT` never reaches the test — the env-var shortcut does not reproduce this): | cpus | `test_make_game_pipelines` | `test_make_game_argparse` | |---|---|---| | 2 | 2 failures | 2 failures | | 3 | 1 failure | 2 failures | | 4 | 1 failure | 2 failures | | 8 | pass | 1 failure | | 256 | pass | pass | At 4 cpus: ``` FAIL: test_jobs_on_the_command_line_reach_the_checker AssertionError: '2' != '5' (tests/test_make_game_pipelines.py:59) FAIL: test_custom_jobs_forwarded_to_shaders mock_preflight.assert_called_once_with(..., jobs=6) (tests/test_make_game_argparse.py:369) ``` 4 and 3 are the sizes of the runners this repository's CI uses (`ubuntu-latest` has 4 cores, `macos-26` is the "three cores" of `ci.yml`), so both Python CI legs are red on `main` for this reason alone. ## Change - Each file gets a small `host_independent_jobs()` helper that patches `leonida_tui.cpu_jobs_bounds` to `(1, 1, 1 << 30)` — an upper bound no host reaches — around the calls that go through `main()`. - The pin is an upper bound, not a realistic number like 64: the *default* path is clamped too, so a low pin would fail on a big machine. - The clamp keeps its own coverage in `test_jobs_default_calculation_scenarios`, which asserts the default computation directly and does not go through `main()`. ## Tested `main` `de4c37383` + this patch, both files, `os.cpu_count()` patched in-process: | cpus | 2 | 3 | 4 | 8 | 16 | 130 | 256 | |---|---|---|---|---|---|---|---| | `test_make_game_argparse.py` | OK | OK | OK | OK | OK | OK | OK | | `test_make_game_pipelines.py` | OK | OK | OK | OK | OK | OK | OK | - Negative control: production `clamp_jobs` forced to `min(2, ...)` — the three tests go red again at 4 cpus (2 argparse / 2 pipelines failures) and 16 cpus (3 / 3), so the pin does not make the assertions vacuous. Restored afterwards. - `python -m compileall -q` on both files, `python -I make_game.py --help`: clean. - Linux only; nothing here touches a Windows path, a GPU or a game file. AI-assisted (Hermes Agent). No game files.
make_game.main() clamps --jobs to the host's CPU count through
leonida_tui.clamp_jobs, so the checks that ask for more jobs than the
machine has compared the clamped value instead of the forwarded one.
Measured on e56d979 with os.cpu_count patched in-process (python -I
implies -E, so PYTHON_CPU_COUNT never reaches the test):

  cpus | test_make_game_pipelines | test_make_game_argparse
     2 | 2 failures               | 2 failures
     3 | 1 failure                | 2 failures
     4 | 1 failure                | 2 failures
     8 | pass                     | 1 failure

4 and 3 are the sizes of the runners this repository's CI uses
(ubuntu-latest has 4 cores, macos-26 is the "three cores" of ci.yml).

Pin leonida_tui.cpu_jobs_bounds to (1, 1, 1 << 30), an upper bound no
host reaches, around the calls that go through main(), so the clamp
cannot move the requested value. The clamp itself keeps its coverage in
test_jobs_default_calculation_scenarios.

Both files pass at 2, 3, 4, 8, 16, 130 and 256 CPUs. Negative control:
clamping main() to min(2, ...) turns the same three tests red again.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:53:22 +00:00
Author
Owner

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

This no longer merges: the conflict is tests/test_make_game_argparse.py, where main already carries the same fix for the --jobs 10 assets case (#1, merged). git merge-tree main old-pr/10056 reports the three-way conflict on that file; the test_make_game_pipelines.py half applies cleanly.

For reference, #83 is a mergeable version of the same two cases (it pins make_game.leonida_tui.os.cpu_count at 16 for the one call in each test rather than reworking them, and was rebased on current main). So either rebase this one or take #83 - the Windows failure (--jobs clamped to the runner's 4 threads) is the same either way.

**@⁠wavehs** on GitHub · 2026-11-24 03:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/322#issuecomment-7120856427) This no longer merges: the conflict is `tests/test_make_game_argparse.py`, where `main` already carries the same fix for the `--jobs 10` assets case (#1, merged). `git merge-tree main old-pr/10056` reports the three-way conflict on that file; the `test_make_game_pipelines.py` half applies cleanly. For reference, #83 is a mergeable version of the same two cases (it pins `make_game.leonida_tui.os.cpu_count` at 16 for the one call in each test rather than reworking them, and was rebased on current `main`). So either rebase this one or take #83 - the Windows failure (`--jobs` clamped to the runner's 4 threads) is the same either way.
Author
Owner

@⁠Dezmonius on GitHub · 2026-11-24 07:47 UTC · original

Windows recheck on main at 1c93c86 after #83 merged. I mocked os.cpu_count() in-process to return 2, 4, or 16, with CPython 3.14.7.

Both argparse forwarding cases now pass (38/38 in the file at all three CPU counts). The pipeline suite still has one failure with two logical CPUs: test_windows_reuses_the_checker_from_the_supplied_runtime_build expects --jobs 3 but sees 2 (17/18 passed). The test is checking checker selection and argument forwarding, and the clamp to 2 is expected for that host.

I ported just the remaining context-manager change to a local copy, using the same test-local CPU pin as #83:

with mock.patch.object(make_game.leonida_tui.os, "cpu_count", return_value=16), \
        ...

Adding that context to the supplied-runtime test gives 18/18 pipeline tests and 38/38 argparse tests at each of 2, 4, and 16 CPUs. The default-jobs test still exercises the simulated host count. The rest of this draft's fixes are already on main.

Synthetic tests only, no GPU or game files. AI-assisted (Codex).

**@⁠Dezmonius** on GitHub · 2026-11-24 07:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/322#issuecomment-7125380631) Windows recheck on `main` at `1c93c86` after #83 merged. I mocked `os.cpu_count()` in-process to return 2, 4, or 16, with CPython 3.14.7. Both argparse forwarding cases now pass (38/38 in the file at all three CPU counts). The pipeline suite still has one failure with two logical CPUs: `test_windows_reuses_the_checker_from_the_supplied_runtime_build` expects `--jobs 3` but sees `2` (17/18 passed). The test is checking checker selection and argument forwarding, and the clamp to 2 is expected for that host. I ported just the remaining context-manager change to a local copy, using the same test-local CPU pin as #83: ```python with mock.patch.object(make_game.leonida_tui.os, "cpu_count", return_value=16), \ ... ``` Adding that context to the supplied-runtime test gives 18/18 pipeline tests and 38/38 argparse tests at each of 2, 4, and 16 CPUs. The default-jobs test still exercises the simulated host count. The rest of this draft's fixes are already on main. Synthetic tests only, no GPU or game files. AI-assisted (Codex).
Author
Owner

@⁠Poussistar on GitHub · 2026-11-24 12:20 UTC · original

I am taking this over, thanks for carrying it. #83 merged at 03:10 and fixed two of the three assertions, which is why this branch conflicts with main; the third one is still host-dependent: tests/test_make_game_pipelines.py::test_windows_reuses_the_checker_from_the_supplied_runtime_build asks for --jobs 3, main() clamps it to the host CPU count, and at 2 CPUs it asserts 2 != 3.

Opened #692 as the rebased, narrowed version of this work (same pin, same wording as the two #83 added). @⁠Andretuta, this one can be closed in favour of #692 unless you prefer to push the rebase here; the original authorship is in the commit message.

Measured at 2, 4 and 256 cores with os.cpu_count patched in-process; negative control removes the pin and the 2-core run is red again. tests/test_make_game_argparse.py passes at all three before and after. No game files, no GPU, AI-assisted.

**@⁠Poussistar** on GitHub · 2026-11-24 12:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/322#issuecomment-7131294758) I am taking this over, thanks for carrying it. #83 merged at 03:10 and fixed two of the three assertions, which is why this branch conflicts with `main`; the third one is still host-dependent: `tests/test_make_game_pipelines.py::test_windows_reuses_the_checker_from_the_supplied_runtime_build` asks for `--jobs 3`, `main()` clamps it to the host CPU count, and at 2 CPUs it asserts `2 != 3`. Opened #692 as the rebased, narrowed version of this work (same pin, same wording as the two #83 added). @⁠Andretuta, this one can be closed in favour of #692 unless you prefer to push the rebase here; the original authorship is in the commit message. Measured at 2, 4 and 256 cores with `os.cpu_count` patched in-process; negative control removes the pin and the 2-core run is red again. `tests/test_make_game_argparse.py` passes at all three before and after. No game files, no GPU, AI-assisted.
github-bot closed this pull request 2026-11-27 04:04:19 +00:00
Author
Owner

@⁠Andretuta on GitHub · 2026-11-27 04:02 UTC · original

Closing carried-over draft: superseded by merged PR #692 (OLD-10056) and #83.

**@⁠Andretuta** on GitHub · 2026-11-27 04:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/322#issuecomment-7209465677) Closing carried-over draft: superseded by merged PR #692 (OLD-10056) and #83.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.