From 95bf05469f203f2039a09bd5b061fe13af9bdc2d Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Wed, 11 Nov 2026 07:41:12 -0400 Subject: [PATCH] tools/ci: --where names the rows that START WITH a name it did not find Raising this from the review of #2160, where I hit it: `--where` matches EXACTLY, which is right -- a substring match would answer for `tmp_path_check_self` when asked about `tmp_path_check`, and a partial match reported AS a registration is exactly the false confidence the tool exists to remove. But the miss and the typo read identically: $ ci_targets_check.py --where submodule_pin submodule_pin NOT REGISTERED (searched CMakeLists.txt and every file it include()s or globs) while the row is `submodule_pin_check`. The same three names in #2160's own body (`submodule_pin`, `tmp_path`, `npu_serve_smoke`) all miss for this reason, and a release verifier reading that line has no way to tell "absent" from "wrong string". Now the miss names the near rows, from the same reader that follows the includes and the glob: submodule_pin NOT REGISTERED (searched CMakeLists.txt and every file it include()s or globs) but 2 row(s) START WITH it -- the row name may be what is wrong, not the registration: submodule_pin_check (cmake/tests-submodule-pin.cmake:26), submodule_pin_check_self (cmake/tests-submodule-pin.cmake:27) and still says nothing extra when nothing starts with the query. The hint never claims a match: the verdict stays NOT REGISTERED and the exit code stays 1. Self-test: two arms added -- "a partial name is offered as a hint when the exact name is absent" and "and no hint is invented when nothing starts with the query". Verified on the real tree: --where submodule_pin / tmp_path / npu_serve_smoke now name 2/2/1 near rows, --where tmp_path_check still answers `cmake/tests-tmp-path.cmake:23`, --where totally_bogus_row is still bare, --check unchanged (9 baselined, none new), copyright.py --check rc 0. Refs #2160. --- tools/ci/ci_targets_check.py | 45 +++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tools/ci/ci_targets_check.py b/tools/ci/ci_targets_check.py index 1aeefb54d..6c8dbc121 100755 --- a/tools/ci/ci_targets_check.py +++ b/tools/ci/ci_targets_check.py @@ -534,6 +534,25 @@ def check(root): +def all_rows(root, cmake_path): + """[(row, site, line)] for every `add_test`/`add_python_test` row the reader can see. + + engine#2160 review: `--where` matches EXACTLY, which is right (a substring match would answer for + `tmp_path_check_self` when asked about `tmp_path_check`). But the miss and the typo read identically: + `--where submodule_pin` says NOT REGISTERED while the row is `submodule_pin_check`. This lists the rows + so a miss can name the near ones without ever calling a partial match a registration. + """ + files = [(os.path.relpath(cmake_path, root), open(cmake_path, encoding="utf-8").read())] + files += family_files(root, files[0][1]) + rows = [] + for rel, text in files: + for i, line in enumerate(continued_lines(text), 1): + m = ROW.match(line) + if m and (m.group(1), rel, i) not in rows: + rows.append((m.group(1), rel, i)) + return rows + + def where_rows(root, cmake_path, wanted): """[(row, site, line)] for each wanted row name, searched in CMakeLists.txt then every included file. @@ -776,6 +795,22 @@ def family_tree(included): print(" FAIL --where reports a row that is registered nowhere"); fails += 1 else: print(" ok --where reports an unregistered row as absent") + # engine#2160 review: a miss and a typo must not read the same. `--where submodule_pin` is a MISS on the + # exact rule and a PREFIX of the real row; the hint names the near rows without calling them a match. + allr = all_rows(td, os.path.join(td, "CMakeLists.txt")) + names = [r for r, _, _ in allr] + if not any(n.startswith("globbed") for n in names): + print(" FAIL the prefix hint has no rows to suggest"); fails += 1 + else: + near = [n for n in names if n.startswith("globbed") and n != "globbed"] + if not near: + print(" FAIL a row that only STARTS WITH the query is not offered as a hint"); fails += 1 + else: + print(" ok a partial name is offered as a hint when the exact name is absent") + if any(n.startswith("absent_row") for n in names): + print(" FAIL a hint was invented for a name nothing starts with"); fails += 1 + else: + print(" ok and no hint is invented when nothing starts with the query") print(f"ci_targets_check --self-test: {fails} failure(s)") return 1 if fails else 0 @@ -795,11 +830,19 @@ def main(argv): root = os.path.abspath(a.root) hits = where_rows(root, os.path.join(root, "CMakeLists.txt"), wanted) found = {row for row, _, _ in hits} + hits_all = all_rows(root, os.path.join(root, "CMakeLists.txt")) for row, rel, line in hits: print(f"{row}\t{rel}:{line}") for row in wanted: if row not in found: - print(f"{row}\tNOT REGISTERED (searched CMakeLists.txt and every file it include()s or globs)") + near = [r for r, _, _ in all_rows(root, os.path.join(root, "CMakeLists.txt")) + if r != row and r.startswith(row)] + hint = "" + if near: + where = {r: f"{rel}:{line}" for r, rel, line in hits_all} + hint = ("\n\t but %d row(s) START WITH it -- the row name may be what is wrong, not the " + "registration: %s" % (len(near), ", ".join(f"{r} ({where.get(r, '?')})" for r in near))) + print(f"{row}\tNOT REGISTERED (searched CMakeLists.txt and every file it include()s or globs){hint}") return 0 if found else 1 if a.check: return check(a.root)