Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/test_native_pso_hashes.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions tools/native_pso_hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dxbc dir> <spirv dir>", file=sys.stderr)
Expand Down
Loading