From 116de82f6ddaa226cf942da17749345c5e5dc87d Mon Sep 17 00:00:00 2001 From: Bram <13451103+Boost9898@users.noreply.github.com> Date: Tue, 24 Nov 2026 14:41:27 +0100 Subject: [PATCH] native_pso_hashes: exit 0 on --help tools/native_pso_hashes.py (#497) imports shader_carve, so test_tool_startup runs it with --help; it took that as a wrong argument count and exited 2, which fails the test on main. -h/--help now print the docstring to stdout and return 0, like mesh_compute_vs.py. --- tests/test_native_pso_hashes.py | 9 +++++++++ tools/native_pso_hashes.py | 3 +++ 2 files changed, 12 insertions(+) diff --git a/tests/test_native_pso_hashes.py b/tests/test_native_pso_hashes.py index 94a73697b6..515e5a1d69 100644 --- a/tests/test_native_pso_hashes.py +++ b/tests/test_native_pso_hashes.py @@ -1,4 +1,6 @@ """tools/native_pso_hashes.py on hand-built DXBC containers and indexes: no game data.""" +import contextlib +import io import json import os import struct @@ -126,6 +128,13 @@ def test_no_index(self): self.assertEqual(tool.main(["x", self.dxbc, self.spirv]), 1) self.assertEqual(tool.main(["x"]), 2) + def test_help_exits_zero(self): + for flag in ("-h", "--help"): + out = io.StringIO() + with contextlib.redirect_stdout(out): + self.assertEqual(tool.main(["x", flag]), 0) + self.assertIn("native_hashes.txt", out.getvalue()) + def test_a_shared_digest_requires_the_same_stage(self): shared = container(bytes([9]) * 16) self.put("one", shared) diff --git a/tools/native_pso_hashes.py b/tools/native_pso_hashes.py index 4b8485ad70..11af33342d 100644 --- a/tools/native_pso_hashes.py +++ b/tools/native_pso_hashes.py @@ -96,6 +96,9 @@ def write(spirv: str, table: dict) -> str: def main(argv) -> int: + if argv[1:] in (["-h"], ["--help"]): + print(__doc__.strip()) + return 0 if len(argv) != 3: print(__doc__.strip().splitlines()[0], file=sys.stderr) print("usage: native_pso_hashes.py ", file=sys.stderr)