From 6544b4a60ff03c721d5cf9c33ef99e5bda39b6b0 Mon Sep 17 00:00:00 2001 From: tedin7 Date: Mon, 23 Nov 2026 05:44:48 +0100 Subject: [PATCH 1/2] test: an all-skipped translator run leaves its exit code to the all-skipped test (main 0c48c1f4) 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 #4448). --- tests/test_shader_diff_exit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_shader_diff_exit.py b/tests/test_shader_diff_exit.py index 7ead6f07e1..8929c511c7 100644 --- a/tests/test_shader_diff_exit.py +++ b/tests/test_shader_diff_exit.py @@ -39,7 +39,7 @@ def test_unsupported_translation_is_a_skip(self): mock.patch.object(sd.rdna2spirv, "translate", side_effect=sd.rdna2spirv.Unsupported("test opcode")), contextlib.redirect_stdout(out), ): - self.assertEqual(sd.main(["--programs", "1"]), 0) + sd.main(["--programs", "1"]) # the exit code of an all-skipped run: see the test below self.assertIn("1 skipped, 0 harness errors", out.getvalue()) self.assertIn("translator unsupported: test opcode", out.getvalue()) From ee42b6897bbc131f3fb099299c7e832681674b04 Mon Sep 17 00:00:00 2001 From: tedin7 Date: Mon, 23 Nov 2026 08:55:27 +0100 Subject: [PATCH 2/2] test: pin the exit order on the cf_diff and mem_diff suite path; wrap two docstring lines --- tests/test_cf_diff.py | 10 ++++++++++ tests/test_mem_diff.py | 12 ++++++++++++ tools/fmisc_diff.py | 3 ++- tools/mem_diff.py | 3 ++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/test_cf_diff.py b/tests/test_cf_diff.py index 03f1913470..19f87d837f 100644 --- a/tests/test_cf_diff.py +++ b/tests/test_cf_diff.py @@ -53,6 +53,16 @@ def test_a_run_where_every_program_was_skipped_is_not_a_success(capsys, monkeypa assert "no program ran: every one was skipped" in capsys.readouterr().out +@pytest.mark.parametrize("status, code", [ + ("mismatch", 1), # every program mismatched: a mismatch is not "nothing ran" + ("match", 0), # every program matched +]) +def test_a_suite_run_exits_by_what_was_compared(status, code, capsys, monkeypatch): + monkeypatch.setattr(cf_diff, "run_case", lambda *args, **kwargs: (status, "detail")) + assert cf_diff.main(["--programs", "2", "--seed", "1"]) == code + assert "no program ran" not in capsys.readouterr().out + + @pytest.mark.parametrize("statuses, code", [ (["skip", "skip"], 2), # nothing was compared (["skip", "mismatch"], 1), # a mismatch outranks "nothing else ran" diff --git a/tests/test_mem_diff.py b/tests/test_mem_diff.py index 7a94f5ec9d..8584834451 100644 --- a/tests/test_mem_diff.py +++ b/tests/test_mem_diff.py @@ -61,6 +61,18 @@ def test_a_run_where_every_program_was_skipped_is_not_a_success(self): self.assertEqual(rc, 2, out.getvalue()) self.assertIn("no program ran: every one was skipped", out.getvalue()) + def test_a_run_exits_by_what_was_compared(self): + import contextlib + import io + from unittest import mock + for status, code in (("mismatch", 1), ("match", 0)): + out = io.StringIO() + with self.subTest(status=status), \ + mock.patch.object(md, "run_one", lambda *args, status=status: (status, "detail")), \ + contextlib.redirect_stdout(out): + self.assertEqual(md.main(["--programs", "2", "--seed", "1"]), code, out.getvalue()) + self.assertNotIn("no program ran", out.getvalue()) + class Reference(unittest.TestCase): """The reference model on hand-made cases (the expected words are worked out by hand).""" diff --git a/tools/fmisc_diff.py b/tools/fmisc_diff.py index 8cc32c2b17..db08199889 100644 --- a/tools/fmisc_diff.py +++ b/tools/fmisc_diff.py @@ -59,7 +59,8 @@ python -I tools/fmisc_diff.py --self-test Exit 0 when every program matches, 1 on a mismatch (the shortest failing program is printed after removing -instructions that do not matter), 2 on a harness error or when every program was skipped (nothing was compared), 77 when the requested hardware oracle is unavailable. +instructions that do not matter), 2 on a harness error or when every program was skipped (nothing was +compared), 77 when the requested hardware oracle is unavailable. Skips are counted with their reasons. """ import argparse diff --git a/tools/mem_diff.py b/tools/mem_diff.py index 7a7ffc93b2..edc7a1031d 100644 --- a/tools/mem_diff.py +++ b/tools/mem_diff.py @@ -31,7 +31,8 @@ python -I tools/mem_diff.py --self-test Exit code 0 when every program matches, 1 on a mismatch (the first one is printed with its listing), 2 on a -harness error or when every program was skipped (nothing was compared). Skips are counted with their reasons, never silent. +harness error or when every program was skipped (nothing was compared). Skips are counted with their reasons, +never silent. """ import argparse import gc