From a9e772c756111cbc3ab1240436cac9084b962d7d Mon Sep 17 00:00:00 2001 From: Atomsk <135618857+Atomsk-debug@users.noreply.github.com> Date: Mon, 9 Nov 2026 12:16:25 +0100 Subject: [PATCH] test_dmsh_abi's ratchet no longer counts "?": the unknown binding kind is also what log lines write for a name they do not have, and the third such placeholder in nvn_mtl.m failed the Tool tests on main (issue #1656) The ratchet counts the ABI's kind names and distinctive numbers written as literals in the files that use the header, so that they do not come back in place of the DMSH_* names. The unknown kind is "?", and nvn_mtl.m also writes "?" in log lines for a shader key, a module name or a pipeline description it does not have: two such placeholders were in the baseline, and the third (70b9a68a, the pipeline archive index) made test_no_new_abi_literals fail on main, {'dm/gfx/nvn/nvn_mtl.m': {"'?'": '2 -> 3'}}, and with it the Tool tests job of every pull request. "?" is not distinctive enough to find as a literal, as 8, 16, 0x20 and 128 are not among the numbers: the ratchet now leaves the unknown kind out and the baseline no longer lists it. The other kinds and the numbers are counted as before. Checked: test_dmsh_abi (10 tests) fails on main and passes with the change. Co-Authored-By: Claude Fable 5.1 --- dm/tools/tests/test_dmsh_abi.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dm/tools/tests/test_dmsh_abi.py b/dm/tools/tests/test_dmsh_abi.py index d9e50968a3..b428ab0bb1 100644 --- a/dm/tools/tests/test_dmsh_abi.py +++ b/dm/tools/tests/test_dmsh_abi.py @@ -16,13 +16,13 @@ import dmsh_abi as abi # noqa: E402 # Literals of the ABI still written in each file (outside comments), counted as the ratchet below does: the value, or the kind string (repr). These stay for other reasons: -# a json key spelled like a kind ('c1', 'geometry', 'tex', 'img' in the facts and reflection json), an NVN stage name ("geometry"), a "?" placeholder in a log line, and 0x100 +# a json key spelled like a kind ('c1', 'geometry', 'tex', 'img' in the facts and reflection json), an NVN stage name ("geometry"), and 0x100 # where it is not the push constant block's size (DMSH_PUSH_SIZE): a viewport swizzle value in nvn_mtl.m, the start of compute code in a package record in dmsh_build.py, # a single texture bind record's flag bit in nvn_obj.h (BIND_TEX1_NOBASE). # 0x1000 where it is not the pool table's entry count (DMSH_GMEM_MAP_ENTRIES): the 4 KB page step of nvn_mtl.m's sparse residency map. # A count may only go down; when it does, lower it here. BASELINE = { - 'dm/gfx/nvn/nvn_mtl.m': {"'?'": 2, "'geometry'": 3, '0x100': 2, '0x1000': 2}, + 'dm/gfx/nvn/nvn_mtl.m': {"'geometry'": 3, '0x100': 2, '0x1000': 2}, 'dm/gfx/nvn/nvn_refl.m': {"'c1'": 1}, 'dm/gfx/nvn/nvn_refl.h': {}, 'dm/gfx/nvn/nvn_obj.h': {'0x100': 1}, @@ -31,6 +31,7 @@ 'dm/gfx/tools/cb_extent.py': {}, } NUMBERS = {v for v in abi.VALUES.values() if isinstance(v, int) and v >= 0x100} # the offsets and sizes distinctive enough to find as literals (not 8, 16, 0x20 or 128) +KINDS = abi.KINDS - {abi.KIND_UNKNOWN} # the kind names distinctive enough: not "?", which log lines also write for a name they do not have (nvn_mtl.m has three such placeholders) C_TOKEN = re.compile(r'"(?:\\.|[^"\\\n])*"|\'(?:\\.|[^\'\\\n])*\'|//[^\n]*|/\*.*?\*/|\b0[xX][0-9A-Fa-f]+\b', re.S) @@ -53,7 +54,7 @@ def py_literals(text): # the same for Python source def abi_literals(path): text = (REPO / path).read_text() lits = py_literals(text) if path.endswith('.py') else c_literals(text) - return collections.Counter(f'{v:#x}' if k == 'int' else repr(v) for k, v in lits if (k == 'int' and v in NUMBERS) or (k == 'str' and v in abi.KINDS)) + return collections.Counter(f'{v:#x}' if k == 'int' else repr(v) for k, v in lits if (k == 'int' and v in NUMBERS) or (k == 'str' and v in KINDS)) class Header(unittest.TestCase):