tests/semantic: skip spirv-as/spirv-val checks when SPIRV-Tools absent (TEST-SOPC-UNARY-SPIRV-TOOLS) #676

Manually merged
github merged 1 commit from gh-pr/676/head into gh-pr/676/base 2026-11-26 09:15:44 +00:00
Owner

@⁠kirigayakazima on GitHub · 2026-11-24 11:37 UTC · original
kirigayakazima:fix/semantic-optional-spirv-tools → main · +204 −140 · 2 files · 1 commits · merged 2026-11-24 17:10 UTC

Claimed in the coordination issue as: TEST-SOPC-UNARY-SPIRV-TOOLS (#14)

What and why

Replaces the SPIRV-Tools half of conflicting draft #136, following @⁠ItsMrDubey's design suggestion in #136 (comment 7121549964) so translation and spirv_mini_interp coverage always run everywhere instead of silently returning early or failing on tool-less hosts (e.g., Windows semantic-tests leg or local dev PCs):

  • tests/semantic/test_sopc_validation.py:
    • Split _translate_and_validate_cs into _translate_cs and _validate_spirv and extract _positive_control_program().
    • test_all_18_ops_and_valid_scalar_operands_interp runs translation + spirv_mini_interp across all 18 SOPC instructions unconditionally.
    • test_all_18_ops_and_valid_scalar_operands_spirv_val checks spirv-as / spirv-val on PATH: skips cleanly when absent and LEONIDA_REQUIRE_SPIRV_TOOLS != "1", and fails loudly via self.fail(...) when LEONIDA_REQUIRE_SPIRV_TOOLS == "1".
  • tests/semantic/test_unary_f16_validation.py:
    • Separate run_ps translation/interpreter execution from validate_spirv and factor out shared shader builders (_combo_opsel_shaders, _nontrivial_opsel_shader, _inplace_sdwa_shader, _positive_control_lines).
    • Add dedicated test_sin_cos_opsel_spirv_val and test_positive_controls_all_12_ops_spirv_val methods using _require_or_skip_spirv_tools (skip when missing and LEONIDA_REQUIRE_SPIRV_TOOLS != "1", fail loudly when LEONIDA_REQUIRE_SPIRV_TOOLS == "1").
    • Keep all negative validation, positive translation, and spirv_mini_interp checks running unconditionally on every host.

Note: on unmodified main (21625bca) without SPIRV-Tools, both files still failed (1/11 in test_sopc_validation.py; 15 subtests in test_unary_f16_validation.py — also hit in #652's Windows run).

Tested

On Windows 11 x64 (Python 3.14.7, spirv-as/spirv-val not on PATH) at efeb1db11bcd632c01246d783f2987114e6e4811, synthetic fixtures only (no game data):

  • Unset & LEONIDA_REQUIRE_SPIRV_TOOLS=0:
    • python -I tests/semantic/test_sopc_validation.py -v — 12 ran, OK (skipped=1) (test_all_18_ops_and_valid_scalar_operands_interp passed)
    • python -I tests/semantic/test_unary_f16_validation.py -v — 7 ran, OK (skipped=2) (all interpreter/negative/positive-translation checks passed)
    • python -I -m unittest discover -s tests/semantic -p ... — both OK
  • LEONIDA_REQUIRE_SPIRV_TOOLS=1 (verifies strict CI failure):
    • test_sopc_validation.py — FAILED (1/12, AssertionError: spirv-as and spirv-val must be on PATH)
    • test_unary_f16_validation.py — FAILED (2/7, AssertionError: spirv-as / spirv-val not found on PATH)
  • python -I tests/test_ci_registration.py — 15 ran, OK
  • python -I tests/test_text_write_line_endings.py — 3 ran, OK
  • python -I scripts/check_no_game_data.py ... & python -m compileall -q ... — exit 0

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main (21625bca) 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. (n/a — semantic tests only)
**@⁠kirigayakazima** on GitHub · 2026-11-24 11:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/676) `kirigayakazima:fix/semantic-optional-spirv-tools` → `main` · +204 −140 · 2 files · 1 commits · merged 2026-11-24 17:10 UTC Claimed in the coordination issue as: TEST-SOPC-UNARY-SPIRV-TOOLS (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why Replaces the SPIRV-Tools half of conflicting draft #136, following @⁠ItsMrDubey's design suggestion in [#136 (comment 7121549964)](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/136) so translation and `spirv_mini_interp` coverage always run everywhere instead of silently returning early or failing on tool-less hosts (e.g., Windows `semantic-tests` leg or local dev PCs): - `tests/semantic/test_sopc_validation.py`: - Split `_translate_and_validate_cs` into `_translate_cs` and `_validate_spirv` and extract `_positive_control_program()`. - `test_all_18_ops_and_valid_scalar_operands_interp` runs translation + `spirv_mini_interp` across all 18 SOPC instructions unconditionally. - `test_all_18_ops_and_valid_scalar_operands_spirv_val` checks `spirv-as` / `spirv-val` on `PATH`: skips cleanly when absent and `LEONIDA_REQUIRE_SPIRV_TOOLS != "1"`, and fails loudly via `self.fail(...)` when `LEONIDA_REQUIRE_SPIRV_TOOLS == "1"`. - `tests/semantic/test_unary_f16_validation.py`: - Separate `run_ps` translation/interpreter execution from `validate_spirv` and factor out shared shader builders (`_combo_opsel_shaders`, `_nontrivial_opsel_shader`, `_inplace_sdwa_shader`, `_positive_control_lines`). - Add dedicated `test_sin_cos_opsel_spirv_val` and `test_positive_controls_all_12_ops_spirv_val` methods using `_require_or_skip_spirv_tools` (skip when missing and `LEONIDA_REQUIRE_SPIRV_TOOLS != "1"`, fail loudly when `LEONIDA_REQUIRE_SPIRV_TOOLS == "1"`). - Keep all negative validation, positive translation, and `spirv_mini_interp` checks running unconditionally on every host. Note: on unmodified `main` (`21625bca`) without SPIRV-Tools, both files still failed (1/11 in `test_sopc_validation.py`; 15 subtests in `test_unary_f16_validation.py` — also hit in #652's Windows run). ### Tested On Windows 11 x64 (`Python 3.14.7`, `spirv-as`/`spirv-val` not on `PATH`) at `efeb1db11bcd632c01246d783f2987114e6e4811`, synthetic fixtures only (no game data): - Unset & `LEONIDA_REQUIRE_SPIRV_TOOLS=0`: - `python -I tests/semantic/test_sopc_validation.py -v` — **12 ran, OK (skipped=1)** (`test_all_18_ops_and_valid_scalar_operands_interp` passed) - `python -I tests/semantic/test_unary_f16_validation.py -v` — **7 ran, OK (skipped=2)** (all interpreter/negative/positive-translation checks passed) - `python -I -m unittest discover -s tests/semantic -p ...` — both OK - `LEONIDA_REQUIRE_SPIRV_TOOLS=1` (verifies strict CI failure): - `test_sopc_validation.py` — FAILED (1/12, `AssertionError: spirv-as and spirv-val must be on PATH`) - `test_unary_f16_validation.py` — FAILED (2/7, `AssertionError: spirv-as / spirv-val not found on PATH`) - `python -I tests/test_ci_registration.py` — **15 ran, OK** - `python -I tests/test_text_write_line_endings.py` — **3 ran, OK** - `python -I scripts/check_no_game_data.py ...` & `python -m compileall -q ...` — exit 0 GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` (`21625bca`) 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. (n/a — semantic tests only)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:15:42 +00:00
github manually merged commit efeb1db11b into gh-pr/676/base 2026-11-26 09:15:44 +00:00
Author
Owner

@⁠trigger337 on GitHub · 2026-11-24 11:40 UTC · original

agent: yes
AI-assisted: yes

Tested on Linux (CachyOS x86_64, Python 3.14):

  1. With SPIRV-Tools on PATH:

    • test_sopc_validation.py: 12/12 ran and passed (both _interp and _spirv_val executed).
    • test_unary_f16_validation.py: 7/7 ran and passed (sin_cos_opsel_spirv_val and positive_controls_all_12_ops_spirv_val validated).
  2. With SPIRV-Tools absent from PATH:

    • Clean skip mode (LEONIDA_REQUIRE_SPIRV_TOOLS=0 / default): test_sopc_validation.py ran 12 tests, 11 passed, 1 skipped cleanly; test_unary_f16_validation.py skipped 2 tests cleanly. All positive/negative translation and spirv_mini_interp suites ran unconditionally.
    • Strict CI mode (LEONIDA_REQUIRE_SPIRV_TOOLS=1): triggered AssertionError: spirv-as and spirv-val must be on PATH loudly as required for CI.
  3. CI Registration & Clean-room Checks:

    • tests/test_ci_registration.py: 15/15 passed.
    • scripts/check_no_game_data.py: clean.
**@⁠trigger337** on GitHub · 2026-11-24 11:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/676#issuecomment-7130409524) agent: yes AI-assisted: yes Tested on Linux (CachyOS x86_64, Python 3.14): 1. **With SPIRV-Tools on `PATH`**: - `test_sopc_validation.py`: 12/12 ran and passed (both `_interp` and `_spirv_val` executed). - `test_unary_f16_validation.py`: 7/7 ran and passed (`sin_cos_opsel_spirv_val` and `positive_controls_all_12_ops_spirv_val` validated). 2. **With SPIRV-Tools absent from `PATH`**: - Clean skip mode (`LEONIDA_REQUIRE_SPIRV_TOOLS=0` / default): `test_sopc_validation.py` ran 12 tests, 11 passed, 1 skipped cleanly; `test_unary_f16_validation.py` skipped 2 tests cleanly. All positive/negative translation and `spirv_mini_interp` suites ran unconditionally. - Strict CI mode (`LEONIDA_REQUIRE_SPIRV_TOOLS=1`): triggered `AssertionError: spirv-as and spirv-val must be on PATH` loudly as required for CI. 3. **CI Registration & Clean-room Checks**: - `tests/test_ci_registration.py`: 15/15 passed. - `scripts/check_no_game_data.py`: clean.
Author
Owner

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

Three open PRs fix the same red files, so here is a side-by-side measured on Windows 11, Python 3.14, without SPIRV-Tools, with scripts/run_semantic_tests.py.

Main (a28927849), measured locally: 465 files, 6108 tests, 2 files red with the variable unset (test_sopc_validation, test_unary_f16_validation: "spirv-as / spirv-val not found on PATH"). On CI, the Windows semantic-tests job of main run 45369028646 (21625bca8) fails on 4 files: those two plus test_active_cache and test_reg_ptr_hoist. Ubuntu passes.

Results for the 4 files at stake, by LEONIDA_REQUIRE_SPIRV_TOOLS value:

PR unset 0 (what ci.yml:193 sets on non-Linux runners) 1
main sopc, unary_f16 red all 4 red all 4 red (expected)
#676 all green active_cache, reg_ptr_hoist red all 4 red (expected)
#940 all green active_cache, reg_ptr_hoist red all 4 red (expected)
#136 all green all green all 4 red (expected)

(test_fma_khr* and test_spirv_tools_required also fail with 1 and no tools, as intended; I left them out of the table.)

What differs:

  1. 0 case. test_active_cache.py:56 and test_reg_ptr_hoist.py:59 test the variable for truthiness, so the '0' that ci.yml sets on Windows counts as "required". That is the Windows CI failure above. Only #136 fixes it, with == "1" as test_fma_khr, test_fma_khr_f64 and test_spirv_tools_required already do.
  2. Skip vs silent pass. #676 splits each validation into its own test and calls skipTest, so a missing tool shows up as a skip in -v output and in the counts, while the interpreter checks still run. #940, and the sopc/unary half of #136, return early instead, so the test passes with no trace that spirv-val did not run. That matches main's existing convention in test_active_cache and test_reg_ptr_hoist, but a skip is at least visible, which is why I would take #676's approach for these two files.
  3. #136's state. It is a draft carry-over and CONFLICTING. Its test_image_atomics_guard half is already on main through #20, #394 and #460, and that file is where the conflict is.

Suggestion: merge #676, and carry #136's two-line == "1" change, either on #676 or as a small separate PR. That makes the Windows semantic-tests job green. #940 and #136 can then close as superseded. I have not touched any of the three branches.

AI-assisted: yes (Claude Code ran the measurements, and a separate agent checked the claims against the code and CI before posting).

**@⁠MoonEyes** on GitHub · 2026-11-24 16:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/676#issuecomment-7137025630) Three open PRs fix the same red files, so here is a side-by-side measured on Windows 11, Python 3.14, **without** SPIRV-Tools, with `scripts/run_semantic_tests.py`. Main (a28927849), measured locally: 465 files, 6108 tests, 2 files red with the variable unset (`test_sopc_validation`, `test_unary_f16_validation`: "spirv-as / spirv-val not found on PATH"). On CI, the Windows `semantic-tests` job of main run 45369028646 (21625bca8) fails on 4 files: those two plus `test_active_cache` and `test_reg_ptr_hoist`. Ubuntu passes. Results for the 4 files at stake, by `LEONIDA_REQUIRE_SPIRV_TOOLS` value: | PR | unset | `0` (what ci.yml:193 sets on non-Linux runners) | `1` | |---|---|---|---| | main | sopc, unary_f16 red | all 4 red | all 4 red (expected) | | #676 | all green | active_cache, reg_ptr_hoist red | all 4 red (expected) | | #940 | all green | active_cache, reg_ptr_hoist red | all 4 red (expected) | | #136 | all green | all green | all 4 red (expected) | (`test_fma_khr*` and `test_spirv_tools_required` also fail with `1` and no tools, as intended; I left them out of the table.) What differs: 1. **`0` case.** `test_active_cache.py:56` and `test_reg_ptr_hoist.py:59` test the variable for truthiness, so the `'0'` that ci.yml sets on Windows counts as "required". That is the Windows CI failure above. Only #136 fixes it, with `== "1"` as `test_fma_khr`, `test_fma_khr_f64` and `test_spirv_tools_required` already do. 2. **Skip vs silent pass.** #676 splits each validation into its own test and calls `skipTest`, so a missing tool shows up as a skip in `-v` output and in the counts, while the interpreter checks still run. #940, and the sopc/unary half of #136, return early instead, so the test passes with no trace that `spirv-val` did not run. That matches main's existing convention in `test_active_cache` and `test_reg_ptr_hoist`, but a skip is at least visible, which is why I would take #676's approach for these two files. 3. **#136's state.** It is a draft carry-over and `CONFLICTING`. Its `test_image_atomics_guard` half is already on main through #20, #394 and #460, and that file is where the conflict is. Suggestion: merge #676, and carry #136's two-line `== "1"` change, either on #676 or as a small separate PR. That makes the Windows `semantic-tests` job green. #940 and #136 can then close as superseded. I have not touched any of the three branches. AI-assisted: yes (Claude Code ran the measurements, and a separate agent checked the claims against the code and CI before posting).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 17:10 UTC · original

Reviewed and merging. Checked on main + this PR, Linux, without game files:

  • No assertion lost in the restructure. The same sopc shader and all 1,140 unary f16 shaders are still translated and checked, and validation still runs the same spirv-val calls.
  • Behaviour:
SPIRV-Tools main this PR
present pass pass
absent both files fail pass, validation shown as skipped
absent, LEONIDA_REQUIRE_SPIRV_TOOLS=1 fail fail
absent, LEONIDA_REQUIRE_SPIRV_TOOLS=0 (Windows CI) fail pass, validation shown as skipped
  • The full semantic suite passes.
  • The red stdlib-tests-linux job is test_tool_stdout_encoding flagging tools/exe_sha.py and tools/pr_conflict_label.py on the main of 13:48. This PR doesn't touch either, and both are fixed on main since.

#940, which covered the same two files, was closed as a duplicate of this one.

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

**@⁠aslan2142** on GitHub · 2026-11-24 17:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/676#issuecomment-7138804131) Reviewed and merging. Checked on `main` + this PR, Linux, without game files: - **No assertion lost in the restructure.** The same sopc shader and all 1,140 unary f16 shaders are still translated and checked, and validation still runs the same `spirv-val` calls. - **Behaviour:** | SPIRV-Tools | `main` | this PR | |---|---|---| | present | pass | pass | | absent | both files fail | pass, validation shown as skipped | | absent, `LEONIDA_REQUIRE_SPIRV_TOOLS=1` | fail | fail | | absent, `LEONIDA_REQUIRE_SPIRV_TOOLS=0` (Windows CI) | fail | pass, validation shown as skipped | - The full semantic suite passes. - The red `stdlib-tests-linux` job is `test_tool_stdout_encoding` flagging `tools/exe_sha.py` and `tools/pr_conflict_label.py` on the `main` of 13:48. This PR doesn't touch either, and both are fixed on `main` since. #940, which covered the same two files, was closed as a duplicate of this one. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.