Skip to content

cf_diff, mem_diff, shader_diff, fmisc_diff: exit 2 when every program was skipped, not 0 (as #4365, #4376) - #4448

Closed
tedin7 wants to merge 4 commits into
ItsNotRexed:mainfrom
tedin7:h1-diff-tools-all-skipped
Closed

tedin7 wants to merge 4 commits into
ItsNotRexed:mainfrom
tedin7:h1-diff-tools-all-skipped

Conversation

@tedin7

@tedin7 tedin7 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Item: new, claimed here.
Depends on: none.

Why

Pattern set by #4365 (wint_diff) and #4376 (vint, pk16, salu, sdwa, sad): a differential run in which every generated program is skipped compared nothing, yet exits 0 ("0 pass, 0 mismatch, N skipped"). crosslane_fuzz.py already exits 2 with "no program ran: every one was skipped". The same gap was still in cf_diff.py, mem_diff.py, shader_diff.py and fmisc_diff.py.

What

After the harness-error and mismatch checks, each tool prints "no program ran: every one was skipped" and returns 2 when no program passed. Runs with some passes and some skips still exit 0. The exit-code line of each module docstring says so.
Left out on purpose: valu_fuzz.py and lds_fuzz.py (already return 2 when ran == 0), valu_int_diff.py (has no skip concept), image_fuzz.py (its translator path counts skips from Vulkan runs and needs its own change), and the files #4365/#4376 edit.
Three existing tests in tests/test_shader_diff_exit.py changed. test_unsupported_interpreter_construct_is_a_skip and its sibling asserted exit 0 for a run whose only program was skipped; they now only check the skip is counted, and a new test asserts exit 2 (another asserts passes mixed with skips still exit 0). test_a_valid_limit_still_runs_that_many_programs mocked run_one with the status "pass", which the suite counts as a skip, so it passed only through the exit-0 rule; it now returns "match".

Tested

Eight new test functions: cf_diff 3 (all-skipped suite run exits 2; a mismatch-only and an all-pass suite run exit 1 and 0, so the check order is pinned; --program exits like the suite), mem_diff 2 (all-skipped exits 2; mismatch-only and all-pass runs exit 1 and 0), fmisc_diff 1, shader_diff 2. The order tests fail if the new check is moved above the mismatch check or turned into "if True", and pass on the real code (tried on both tools). The all-skipped tests fail on main (exit 0) and pass here. The five test files (cf_diff, mem_diff, fmisc_diff, shader_diff, shader_diff_exit) pass: 115 tests, on a RunPod CPU.
AI-assisted. No game files.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this at 6caeae4a on Windows 11: pytest tests/test_cf_diff.py tests/test_fmisc_diff.py tests/test_mem_diff.py tests/test_shader_diff_exit.py -q -> 89 passed, 56 subtests passed; git diff --check clean.

The four diff tools now exit 2 when every program was skipped, matching #4365/#4376, and the existing diff tests pass. No blocking issue.

@SebSilent

Copy link
Copy Markdown
Contributor

Independent check of the head (CPU only, Linux, Turing box, no pytest installed so test_cf_diff.py is the one file I could not execute here and leave to CI):

  • compileall over the four tools and their tests: clean.
  • Red/green swap with real tool binaries: with the four tools from 03b09a0 and this branch's tests, all three unittest files fail on the new cases; with this branch's tools, test_fmisc_diff.py, test_mem_diff.py and tests/test_shader_diff_exit.py all pass.
  • The semantic change reads correctly and consistently across the four tools: a run where every program was skipped compares nothing, so exit 2 with the reason line rather than a green 0, while some-skips-next-to-passes stays 0 (new positive control included).
  • Two latent test typos get fixed on the way (the stale ('pass', '') label where run_one returns ('match', ''), and the run_fragment skip case that now asserts 2), which is why the existing files change.

No game data or GPU involved. AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 6caeae4 merged with main 03b09a0 on Linux (WSL2), Python 3.12.16: pass. tests/test_fmisc_diff.py, test_mem_diff.py, test_shader_diff_exit.py, test_shader_diff.py run with python -I exit 0; tests/test_cf_diff.py (a pytest file) with -m pytest: 38 passed. Negative control: tools/ restored from main with the PR tests kept -> test_fmisc_diff, test_mem_diff and test_shader_diff_exit exit 1, and in test_cf_diff exactly the new test_a_run_where_every_program_was_skipped_is_not_a_success fails (1 failed, 37 passed). Diff read: counts["pass"] exists in all four tools, the new check runs after the mismatch/harness-error returns so those exit codes are unchanged, and the usage docstrings are updated. No concerns.

@dev-ewann

Copy link
Copy Markdown
Contributor

Reviewed and tested 6caeae4 (already on top of main 03b09a0, so the merge is a fast-forward): looks good.

  • python3 -I -B tests/test_fmisc_diff.py (20 tests), tests/test_mem_diff.py (17), tests/test_shader_diff_exit.py (14): all OK, exit 0. python3 -B -m pytest -p no:cacheprovider tests/test_cf_diff.py -q: 38 passed.
  • Real runs python3 -I -B tools/{cf_diff,mem_diff,shader_diff}.py --programs 2 --seed 1 and fmisc_diff.py --programs 2 --seed 1 --ops v_cvt_u32_f32: all exit 0 with "pass" counts > 0.
  • The four tools behave the same: a mismatch gives 1, no program passed gives 2 with no program ran: every one was skipped, otherwise 0. fmisc_diff keeps 77 for a missing hardware oracle. docs/ does not describe these tools' exit codes, so nothing to update there.
  • Mutations of each added line in the 4 tools (if not counts["pass"] -> if False / inverted, return 2 -> return 1 / return 0, message changed): 20/20 killed.
  • Not killed: the final return 0 -> return 1 in cf_diff.py and mem_diff.py, and the return 1 under if counts["mismatch"]: -> return 0 in those two files. Their tests only call main() on an all-skipped run, never on a green or mismatching one. This was already uncovered on main (return 1 if counts["mismatch"] else 0), so not blocking; one test for each would close it.
  • Nit: the new docstring lines in fmisc_diff.py and mem_diff.py are longer than the surrounding wrap.

Python 3.14.4 and pytest 9.0.2 on WSL2 Ubuntu; no GPU used (CPU only). AI-assisted (Claude), on behalf of dev-ewann.

@Flyander Flyander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 6caeae4: the all-skipped case exits 2 after mismatch and harness-error checks, so existing failure precedence is preserved. The four tools follow the behavior established in #4365 and #4376; independent Linux and Windows test reports pass.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 6caeae4a on Linux (Ubuntu), CPython 3.10.12, pytest 9.2.0, CPU only, no game files: pass.

  • python -I: test_fmisc_diff.py 20 OK, test_mem_diff.py OK, test_shader_diff_exit.py 14 OK; python -m pytest -q: test_shader_diff.py 17 passed, test_cf_diff.py 38 passed.
  • Negative control: with main's four tools restored, test_a_run_where_every_program_was_skipped_is_not_a_success fails (exit 0 instead of 2).
  • git diff --check clean; compileall clean.

AI-assisted (Devin).

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up from our own extra review (and thanks to Kam471, Flyander, SebSilent, kapitche, dev-ewann and Atomic258 for the runs): the single-program path still exited 0 when its program was skipped. Fixed in 50fe243.

Verified first: cf_diff.py --program K (the single-program path) returned 0 when run_case skipped the program, so nothing was compared and the exit was green. A parametrized test reproduces it (the all-skipped case returned 0 before).

What changed: the single-program path now uses the suite's precedence: a mismatch gives 1, otherwise a run where no wave matched (every wave skipped) prints "no program ran: every one was skipped" and gives 2, otherwise 0. With --wave both, one wave skipped next to one that matched stays 0, like the suite. A harness error still ends as a traceback, as before.

Same path in the other tools: mem_diff, shader_diff and fmisc_diff have no single-program mode (only --programs N through run_suite), which already has the all-skipped exit from this PR, so nothing to change there.

Tests (Proxmox, Python 3.13): tests/test_cf_diff.py 41 passed (3 new cases: skip+skip -> 2, skip+mismatch -> 1, match+skip -> 0; the first fails on the previous commit); tests/semantic/test_spirv_wave_interp.py 11 passed.

@mrbean56

Copy link
Copy Markdown

Tested 50fe243d3e on Linux (Debian 13), Python 3.13.5: pass.

  • pytest tests/test_cf_diff.py tests/test_mem_diff.py tests/test_shader_diff.py tests/test_fmisc_diff.py tests/test_shader_diff_exit.py -q: 95 passed, 56 subtests passed.
  • Negative control: with all four tools restored from 03b09a08 and the branch's tests kept, 5 tests fail, including one per tool.
  • Exit ordering is right in all four: harness error → 2, mismatch → 1, not counts["pass"] → 2, so "nothing was compared" can never mask a real mismatch. cf_diff --program now counts status == "match" and the test pins all three orderings (skip,skip → 2, skip,mismatch → 1, match,skip → 0).
  • run_case only ever returns match/mismatch/skip, so matched == 0 genuinely means nothing was compared rather than an unhandled status.

No GPU, no game data. AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 50fe243 merged with main 98fa503 on Linux (Python 3.12.16): fail - test_fmisc_diff 20 OK, test_mem_diff 17 OK, test_cf_diff (pytest) 42 passed, but tests/test_shader_diff_exit.py fails 1 of 16: HarnessErrorExit.test_unsupported_translation_is_a_skip asserts sd.main(['--programs','1']) == 0 with every program skipped (translator Unsupported), and with this PR it returns 2 (AssertionError: 2 != 0). That test arrived on main in 0c48c1f (TEST-807) after this branch forked, so it needs the same update as the skipped-construct test (drop the exit-code assert, or mix in a pass); main alone passes it. Negative control: tools/{cf,fmisc,mem,shader}_diff.py restored from main with the PR tests kept -> cf_diff 2 failed/40 passed, fmisc_diff, mem_diff, shader_diff_exit each FAILED (failures=1).

…kipped test (main 0c48c1f)

test_unsupported_translation_is_a_skip came to main with TEST-807 after this branch forked and asserted exit 0
for a run where every program was skipped, which this PR makes exit 2. It now checks the skip report only, as
test_unsupported_interpreter_construct_is_a_skip does; test_a_run_where_every_program_was_skipped_is_not_a_success
pins the exit code (kapitche on ItsNotRexed#4448).
@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @kapitche, right: test_unsupported_translation_is_a_skip came to main with TEST-807 (0c48c1f) after this branch forked and still asserted exit 0 for a run where every program was skipped. Fixed in 6544b4a6 (main merged in, then the test updated the same way as test_unsupported_interpreter_construct_is_a_skip): it checks the skip report, and test_a_run_where_every_program_was_skipped_is_not_a_success keeps pinning the exit code.

On Linux, Python 3.13: test_fmisc_diff, test_mem_diff, test_shader_diff_exit (16 tests) and test_shader_diff exit 0 under python -I; tests/test_cf_diff.py 42 passed.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 6544b4a merged with main 98fa503 on Linux (WSL2), Python 3.12.16: pass. The earlier concern (tests/test_shader_diff_exit.py::HarnessErrorExit.test_unsupported_translation_is_a_skip returning 2 instead of 0) is resolved.

  • python -I: test_fmisc_diff 20 OK, test_mem_diff 17 OK, test_shader_diff_exit 16 OK, test_shader_diff exit 0; -m pytest tests/test_cf_diff.py: 42 passed.
  • Negative control: tools/{cf,fmisc,mem,shader}_diff.py restored from main with the PR tests kept -> test_fmisc_diff, test_mem_diff and test_shader_diff_exit each exit 1, test_cf_diff 2 failed / 40 passed; tools restored from the PR -> all green again.
  • No further concerns. Linux only (no platform-specific code touched).

@KkelebekK

Copy link
Copy Markdown

Reviewed and tested 6544b4a6 merged with main 3faac557, CPU only: Linux, Python 3.14 (unittest) and 3.12 (pytest 9.2), no GPU, no game data. Looks good, with one test gap.

Test gap: the body says the new check runs "after the harness-error and mismatch checks", but in cf_diff.py and mem_diff.py nothing tests that order on the suite path. If if not counts["pass"] is moved above if counts["mismatch"], a run where every program mismatched exits 2 instead of 1, and the full test files still pass. The same goes for changing it to if True (every green run exits 2), as noted earlier. The order is pinned in shader_diff and fmisc_diff, and on cf_diff --program. Two main() tests per tool would close it, one with a mismatch-only run and one with an all-pass run.

Nits: the body still lists "the four new tests" and "Two existing tests ... changed", but there are now more of both. The fmisc_diff.py docstring line is 166 characters long.

AI-assisted.

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @KkelebekK. Closed in ee42b689:

  • cf_diff and mem_diff: each now has a main() suite-path test with two runs. A mismatch-only run must exit 1, and an all-pass run must exit 0.
  • The mutations: I checked both on the two tools. With the all-skipped check moved above the mismatch check, the two mismatch cases fail. With if True, the two all-pass cases fail. On the real code, both pass.
  • The nits: the long docstring lines in fmisc_diff.py and mem_diff.py are wrapped. The description now counts 8 new test functions (cf_diff 3, mem_diff 2, fmisc_diff 1, shader_diff 2) and 3 changed ones.

The five test files: 115 tests pass on Linux, Python 3.13.

@Andretuta

Copy link
Copy Markdown
Contributor

Tested ee42b6897 on Linux (Python 3.12): pass.

No game files. AI-assisted review (Devin).

@MichaelL401

Copy link
Copy Markdown
Contributor

Tested ee42b689 on Linux, CPU only (no GPU), Python 3.12.16: pass.

  • python -m pytest -q tests/test_cf_diff.py tests/test_fmisc_diff.py tests/test_mem_diff.py tests/test_shader_diff_exit.py: all pass, both on the head and merged onto current main 3faac557 (the branch is 8 commits behind and merges cleanly).
  • Negative control with main's four tools: test_cf_diff 2 failed, test_fmisc_diff 1 failure, test_mem_diff + test_shader_diff_exit 2 failed.

Code read: in each tool, a mismatch (1) and a harness error (2) still take precedence; only a run with no pass at all now exits 2 with "no program ran: every one was skipped". A mix of skips and passes still exits 0.

AI-assisted (Claude).

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at ee42b68 (test: pin the exit order on the cf_diff and mem_diff suite path; ...).

Commands (worktree review-4448, detached at pr/4448):

  • python -I -m pytest tests/test_cf_diff.py tests/test_mem_diff.py tests/test_fmisc_diff.py tests/test_shader_diff_exit.py -q
    -> 98 passed, 61 subtests passed (11.5 s)
  • python -I -m pytest tests/test_shader_diff.py -q -> 17 passed (regression check of the other shader_diff suite)
  • git diff --check -> clean

The new branch only fires when nothing was compared: harness error (2) first, then mismatch (1), then all-skipped (2),
else 0. Tests pin all three orderings on the suite path and the --program path, and keep "some skips beside passes
still exits 0". 0 -> 2 for an all-skipped run is the stated intent (#4365/#4376); no in-repo caller relies on the old 0.

Verdict: LGTM.

ItsNotRexed added a commit that referenced this pull request Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gregoirener pushed a commit to gregoirener/Leonida-latest-backup-Monday-23-nov-Japanese-time- that referenced this pull request Nov 23, 2026
…ed shader_diff run exits 2 (ItsNotRexed#4448)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	tests/test_shader_diff_exit.py
@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 7f8d39d8 merged onto main 561b65a8 on Windows 11, CPython 3.14.3, CPU only: pass.

  • python -I -m pytest -q tests/test_cf_diff.py: 44 passed.
  • python -I tests/test_mem_diff.py: 20 tests OK.
  • python -I tests/test_shader_diff_exit.py: 16 tests OK.
  • Negative control (tools/fmisc_diff.py, tools/mem_diff.py from main, the PR's tests kept): the tests still pass.
  • py_compile on the 5 changed Python files: OK; git diff --check: clean.

No game files. AI-assisted (Claude Code).

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing: main already has this PR's change. It came in through merge 76cf23f5 ("Merge pull request #4448 from tedin7") on 22/11, which carries the exit-2 rule for all four tools and their tests. The PR stayed open because later commits were pushed after that merge. What's left on the branch is one more test of existing exit codes and a docstring line wrap, which isn't worth a PR. @JRamos1993's negative control matches this. AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.