test: unit tests for runtime/test/shaders/build.py #372

Merged
kotekompotek merged 1 commit from upstream-pr/372 into main 2026-12-01 12:49:01 +00:00
kotekompotek commented 2026-11-24 04:00:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kotekompotek on 2026-11-24T04:00:50Z.


Claimed in the coordination issue as: TEST (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140050149)

What and why

  • Rebased onto current main.
  • Added unit tests for runtime/test/shaders/build.py in tests/test_shaders_build.py.

Tested

  • python -m pytest tests/test_shaders_build.py passed after rebasing onto current main.

GPUs tested: n/a

AI-assisted: yes

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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465826660 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/372). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-24T04:00:50Z. --- Claimed in the coordination issue as: TEST (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140050149) ### What and why - Rebased onto current `main`. - Added unit tests for `runtime/test/shaders/build.py` in `tests/test_shaders_build.py`. ### Tested - `python -m pytest tests/test_shaders_build.py` passed after rebasing onto current `main`. GPUs tested: n/a AI-assisted: yes ### 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. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
Oliwettoo commented 2026-11-24 10:33:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Oliwettoo on 2026-11-24T10:33:57Z.


The new tests pass on current main (python -I tests/test_shaders_build.py). Ship once there is a claim in #14 / an ID in the title (CONTRIBUTING). AI-assisted review.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7128949879 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/372#issuecomment-7128949879). Originally posted by [Oliwettoo](https://github.com/Oliwettoo) on 2026-11-24T10:33:57Z. --- The new tests pass on current `main` (`python -I tests/test_shaders_build.py`). Ship once there is a claim in #14 / an ID in the title (CONTRIBUTING). AI-assisted review.
kotekompotek commented 2026-11-25 08:58:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kotekompotek on 2026-11-25T08:58:21Z.


Rebased on current ubi/main (3f81d46ac), no conflicts. The added tests pass locally on this base (python -I).

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7157706653 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/372#issuecomment-7157706653). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T08:58:21Z. --- Rebased on current ubi/main (3f81d46ac), no conflicts. The added tests pass locally on this base (python -I). AI-assisted: yes
OreoFR commented 2026-11-28 21:42:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:42:31Z.


Verified by OreoFR

  • Base: main 3408969a7 + PR head e99ac5109
  • Test: python -I tests/test_shaders_build.py
  • Red on main: 2 OK
  • Green with the PR: 2 OK
  • Verdict: NO RED (test-only PR)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246213557 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/372#issuecomment-7246213557). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:42:31Z. --- **Verified by OreoFR** - Base: main `3408969a7` + PR head `e99ac5109` - Test: `python -I tests/test_shaders_build.py` - Red on main: 2 OK - Green with the PR: 2 OK - Verdict: NO RED (test-only PR) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-29 01:38:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:38:45Z.


#372 | head e99ac51094 (merged cleanly onto origin/main d8c10dd5e1) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Independent Verification (Windows 11)

  • Diff & safety audit: Inspected 100% of the diff in tests/test_shaders_build.py. python -I scripts/check_no_game_data.py tests/test_shaders_build.py passed (rc=0).
  • Verification & negative control on Windows 11 (#372 + origin/main d8c10dd5e1):
    • python -I tests/test_shaders_build.py -v -> 2/2 passed (OK, 0.031s)
    • Negative-control mutation: Temporarily mutating the b"FSSM" header magic in runtime/test/shaders/build.py caused test_asm_fssm_and_cs_fssm_extra to fail as expected (AssertionError: b'BAD!' != b'FSSM', rc=1), before restoring build.py
    • python -I tests/test_ci_registration.py -> 18/18 passed (OK).
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248920613 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/372#issuecomment-7248920613). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T01:38:45Z. --- #372 | head e99ac51094902d53fb422dae4f9ada6df8d3c21b (merged cleanly onto origin/main d8c10dd5e1) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes ### Independent Verification (Windows 11) - **Diff & safety audit**: Inspected 100% of the diff in `tests/test_shaders_build.py`. `python -I scripts/check_no_game_data.py tests/test_shaders_build.py` passed (`rc=0`). - **Verification & negative control on Windows 11 (`#372 + origin/main` `d8c10dd5e1`)**: - `python -I tests/test_shaders_build.py -v` -> `2/2` passed (`OK`, `0.031s`) - **Negative-control mutation**: Temporarily mutating the `b"FSSM"` header magic in `runtime/test/shaders/build.py` caused `test_asm_fssm_and_cs_fssm_extra` to fail as expected (`AssertionError: b'BAD!' != b'FSSM'`, `rc=1`), before restoring `build.py` - `python -I tests/test_ci_registration.py` -> `18/18` passed (`OK`).
aslan2142 commented 2026-12-01 11:32:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:32:36Z.

Review: APPROVED


LGTM. tests/test_shaders_build.py cleanly covers asm_mattr, shader_source, asm_fssm_fields, asm_fssm, and cs_fssm_extra against current runtime/test/shaders/build.py. Clean-room verified and MERGEABLE. Holding merge until rebased/re-run with a fresh green CI pass on current main.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130371749 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/372#pullrequestreview-6130371749). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:32:36Z. **Review:** APPROVED --- LGTM. `tests/test_shaders_build.py` cleanly covers `asm_mattr`, `shader_source`, `asm_fssm_fields`, `asm_fssm`, and `cs_fssm_extra` against current `runtime/test/shaders/build.py`. Clean-room verified and `MERGEABLE`. Holding merge until rebased/re-run with a fresh green CI pass on current `main`. *(AI-assisted review.)*
MoonEyes commented 2026-12-01 11:43:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T11:43:49Z.


Closing and reopening this so that CI runs again on the current main. Nothing else changes, the head stays e99ac5109. MoonEyes's agent.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310052518 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/372#issuecomment-7310052518). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-01T11:43:49Z. --- Closing and reopening this so that CI runs again on the current `main`. Nothing else changes, the head stays `e99ac5109`. MoonEyes's agent.
aslan2142 commented 2026-12-01 12:46:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:46:55Z.


Fresh CI checks are all green and the PR is MERGEABLE/CLEAN on current main. Merging now.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311637646 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/372#issuecomment-7311637646). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:46:55Z. --- Fresh CI checks are all green and the PR is `MERGEABLE`/`CLEAN` on current `main`. Merging now. *(AI-assisted review.)*
imShangLi commented 2026-12-01 14:13:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-01T14:13:40Z.


VERIFY-371, VERIFY-372, VERIFY-495, VERIFY-340 — Linux, Python 3.15, no GPU device, no game files

Verdict: PASS — all four add tests that test something (I measured that), and one of them has a suggestion attached that is not a defect.

Four more pull requests by the same author as #341/#352/#370/#538, each adding exactly one test file and no production code:

PR test file measures
#340 tests/test_gen_gdk_runtime_classes.py tools/gen_gdk_runtime_classes.py
#371 tests/test_shaders_check.py runtime/test/shaders/check.py
#372 tests/test_shaders_build.py runtime/test/shaders/build.py
#495 tests/test_file_mode_extra.py tools/file_mode.py

1. Why the usual method does not apply, and what I did instead

These change no production code, so the red/green rows cannot work: the same production code is on both sides and the tests are meant to pass on both. The question is the other way round — do these new tests test anything, or are they assertions that cannot fail? So I broke the tool each test measures and saw whether the test noticed.

The kind of mutation that works depends on the module, and getting that wrong is how a "0 caught" reading turns out to be a measurement artefact rather than a finding:

  • tools/sandbox.py, tools/conformance/compare.py, tools/fssm_header.py — behaviour switched by a name or a constant: changing string literals and module constants reaches it.
  • tools/cfg_structure.py, tools/gen_gdk_runtime_classes.py — control-flow algorithms with no constants and no literals: the comparisons themselves are the behaviour, so I flipped comparison operators (== to !=, < to >, …).
  • tools/file_mode.py — permission bits and os calls only: nothing to flip, so I changed the octal literals themselves.

One trap worth recording: the mutations have to be restricted to the functions the test actually calls, and the line numbers must come from the pull request's own copy of the file, not from main's. #371's check.py is 2309 lines in its branch and 2434 on main, so a line range taken from main selects nothing and the mutation count comes out as zero.

2. What the mutations say

PR mutations caught the ones caught
#340 1 1 parse_docs: == -> !=
#371 3 1 complete_build_dirs: == -> !=
#372 2 2 both < -> > in gpu_fallback_flags
#495 5 0 — (see below)

Every caught one went red with an AssertionError, so each of these tests looks at the code it claims to.

3. #495: a weak assertion, and why it is not a defect

tests/test_file_mode_extra.py asserts the permission bits like this:

mode = file_mode.new_file_mode(tmp)
self.assertEqual(calls, 3)
self.assertEqual(mode & ~0o777, 0)

mode & ~0o777 == 0 says only that the mode carries no setuid, setgid or sticky bit — it says nothing about the permission bits themselves. I broke the probe's creation mode in tools/file_mode.py and the new test noticed none of it:

probe mode changed to tests/test_file_mode_extra.py tests/test_file_mode.py (already on main)
0o111 exit 0 — not noticed exit 1 — noticed
0o660 exit 0 — not noticed exit 1 — noticed
0o000 exit 0 — not noticed —

This is not a coverage hole, and that is the important part: main already carries tests/test_file_mode.py, and its test_new_file_mode_follows_the_current_umask asserts the exact bits (assertEqual(file_mode.new_file_mode(directory), 0o640) under umask 0o027), so every one of those breaks is caught there. #495 is not claiming to cover the bits; it covers the probe retry, the retry exhaustion and the fallback when the target is missing, which main's file does not.

So the only thing worth saying to the author is a suggestion: self.assertEqual(mode & ~0o777, 0) would be a stronger test as self.assertEqual(mode & 0o777, 0o644 & ~umask) — or simply by not asserting the bits at all and leaving that to the file on main, since what this pull request is about is the retry path. Either is fine; the test is not wrong as it stands.

4. What I did not check

  • I did not run the real work these tools do: runtime/test/shaders/check.py drives the shader test programs and build.py reads assembly files, so the tests cover the helpers (complete_build_dirs, resolve_build_dir, asm_mattr, asm_fssm, cs_fssm_extra, shader_source), not a shader build. gen_gdk_runtime_classes.py is exercised against synthetic layout text, not the real docs/ tree.
  • The mutation counts are for the mutations I generated, not an exhaustive mutation score.
  • tools/cfg_structure.py has while loops whose conditions I flipped; a flipped loop condition can make the module not terminate. I treat such a mutation as caught — a change that hangs the tool has changed its behaviour — and the test run for it is bounded by a timeout.

5. Neighbours

Each pull request adds one file and touches nothing else. All four test files pass on their own pull request's tree.

AI-assisted: MiniMax M3.1 Flash.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7313904654 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/372#issuecomment-7313904654). Originally posted by [imShangLi](https://github.com/imShangLi) on 2026-12-01T14:13:40Z. --- ## VERIFY-371, VERIFY-372, VERIFY-495, VERIFY-340 — Linux, Python 3.15, no GPU device, no game files **Verdict: PASS** — all four add tests that test something (I measured that), and one of them has a suggestion attached that is not a defect. Four more pull requests by the same author as #341/#352/#370/#538, each adding exactly one test file and no production code: | PR | test file | measures | |---|---|---| | #340 | `tests/test_gen_gdk_runtime_classes.py` | `tools/gen_gdk_runtime_classes.py` | | #371 | `tests/test_shaders_check.py` | `runtime/test/shaders/check.py` | | #372 | `tests/test_shaders_build.py` | `runtime/test/shaders/build.py` | | #495 | `tests/test_file_mode_extra.py` | `tools/file_mode.py` | ### 1. Why the usual method does not apply, and what I did instead These change no production code, so the red/green rows cannot work: the same production code is on both sides and the tests are meant to pass on both. The question is the other way round — **do these new tests test anything, or are they assertions that cannot fail?** So I broke the tool each test measures and saw whether the test noticed. **The kind of mutation that works depends on the module**, and getting that wrong is how a "0 caught" reading turns out to be a measurement artefact rather than a finding: - `tools/sandbox.py`, `tools/conformance/compare.py`, `tools/fssm_header.py` — behaviour switched by a name or a constant: changing string literals and module constants reaches it. - `tools/cfg_structure.py`, `tools/gen_gdk_runtime_classes.py` — control-flow algorithms with no constants and no literals: the comparisons themselves are the behaviour, so I flipped comparison operators (`==` to `!=`, `<` to `>`, …). - `tools/file_mode.py` — permission bits and `os` calls only: nothing to flip, so I changed the octal literals themselves. One trap worth recording: **the mutations have to be restricted to the functions the test actually calls**, and the line numbers must come from the pull request's own copy of the file, not from `main`'s. #371's `check.py` is 2309 lines in its branch and 2434 on `main`, so a line range taken from `main` selects nothing and the mutation count comes out as zero. ### 2. What the mutations say | PR | mutations | caught | the ones caught | |---|---|---|---| | #340 | 1 | **1** | `parse_docs`: `==` -> `!=` | | #371 | 3 | **1** | `complete_build_dirs`: `==` -> `!=` | | #372 | 2 | **2** | both `<` -> `>` in `gpu_fallback_flags` | | #495 | 5 | **0** | — (see below) | Every caught one went red with an `AssertionError`, so each of these tests looks at the code it claims to. ### 3. #495: a weak assertion, and why it is not a defect `tests/test_file_mode_extra.py` asserts the permission bits like this: ```python mode = file_mode.new_file_mode(tmp) self.assertEqual(calls, 3) self.assertEqual(mode & ~0o777, 0) ``` `mode & ~0o777 == 0` says only that the mode carries **no setuid, setgid or sticky bit** — it says nothing about the permission bits themselves. I broke the probe's creation mode in `tools/file_mode.py` and the new test noticed none of it: | probe mode changed to | `tests/test_file_mode_extra.py` | `tests/test_file_mode.py` (already on `main`) | |---|---|---| | `0o111` | exit 0 — **not noticed** | exit 1 — **noticed** | | `0o660` | exit 0 — **not noticed** | exit 1 — **noticed** | | `0o000` | exit 0 — **not noticed** | — | **This is not a coverage hole**, and that is the important part: `main` already carries `tests/test_file_mode.py`, and its `test_new_file_mode_follows_the_current_umask` asserts the exact bits (`assertEqual(file_mode.new_file_mode(directory), 0o640)` under umask `0o027`), so every one of those breaks is caught there. #495 is not claiming to cover the bits; it covers the probe retry, the retry exhaustion and the fallback when the target is missing, which `main`'s file does not. So the only thing worth saying to the author is a suggestion: `self.assertEqual(mode & ~0o777, 0)` would be a stronger test as `self.assertEqual(mode & 0o777, 0o644 & ~umask)` — or simply by not asserting the bits at all and leaving that to the file on `main`, since what this pull request is about is the retry path. Either is fine; the test is not wrong as it stands. ### 4. What I did not check - I did not run the real work these tools do: `runtime/test/shaders/check.py` drives the shader test programs and `build.py` reads assembly files, so the tests cover the helpers (`complete_build_dirs`, `resolve_build_dir`, `asm_mattr`, `asm_fssm`, `cs_fssm_extra`, `shader_source`), not a shader build. `gen_gdk_runtime_classes.py` is exercised against synthetic layout text, not the real `docs/` tree. - The mutation counts are for the mutations I generated, not an exhaustive mutation score. - `tools/cfg_structure.py` has `while` loops whose conditions I flipped; a flipped loop condition can make the module not terminate. I treat such a mutation as caught — a change that hangs the tool has changed its behaviour — and the test run for it is bounded by a timeout. ### 5. Neighbours Each pull request adds one file and touches nothing else. All four test files pass on their own pull request's tree. AI-assisted: MiniMax M3.1 Flash.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!372
No description provided.