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

Open
opened 2026-11-26 20:17:40 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/322
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/10056


📝 Commits (1)

  • 809eca2 tests: the make_game --jobs tests no longer depend on the host's core count

📊 Changes

2 files changed (+26 additions, -4 deletions)

View changed files

📝 tests/test_make_game_argparse.py (+12 -2)
📝 tests/test_make_game_pipelines.py (+14 -2)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/322 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/10056` --- ### 📝 Commits (1) - [`809eca2`](https://github.com/ubiquitarianism/leonida/commit/809eca2a9baf80673f6a375de943f7a234142c19) tests: the make_game --jobs tests no longer depend on the host's core count ### 📊 Changes **2 files changed** (+26 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_make_game_argparse.py` (+12 -2) 📝 `tests/test_make_game_pipelines.py` (+14 -2) </details> ### 📄 Description > 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#373
No description provided.