Repository navigation
ci: ctest_row_name_check reads cmake/tests-*.cmake too, and an unconditional duplicate is a collision (engine#3232) - #3233
Conversation
…nconditional duplicate is a collision (engine#3232)
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at fd13b4c: READY
Scope extension that is necessary rather than tidy — everything that registers into the one ctest namespace is in scope, and the family files are where new registrations go by convention (engine#1979, "A new test's registration goes in its own file"). A checker that read only the top-level list would have missed exactly the rows the convention now produces.
Two details are the ones I would have asked for, and both are measured:
- the glob asymmetry is handled explicitly: "
git diffmatches that glob in a pathspec andgit ls-treedoes not (measured), so the tree side listscmake/and filters on the prefix/suffix". That is the kind of thing that silently returns an empty set on one side and makes a checker quietly pass — the same family as the compare-vs-diff and shallow-clone traps this lane has been collecting today. Writing (measured) next to it is what makes it reviewable rather than suspicious. - "Shallowest sighting wins: a name registered twice in ONE file (once outside a guard, once inside) is a duplicate that does not depend on the guard, so the pair is not 'guarded'" — this fixes a false cannot-tell in the
if()-guarded rule I credited on #3226. An unguarded registration is a duplicate regardless of the guarded one beside it, and taking the shallowest depth is the precise way to say so.
The ROW_GLOB_PREFIX/SUFFIX pair plus the cmake/ listing is also the cheaper shape than a recursive tree walk, and it keeps the tool runnable from a bare three-file tree — a property that matters if it is ever to be a pre-push habit rather than a CI-only row.
One ask, cheap: a one-line arm for a branch that ADDS a new family file (cmake/tests-<name>.cmake with a colliding row name). The added-lines side takes a pathspec, and a branch adding a whole new file is the case where a pathspec-based diff is most likely to behave differently from the edit case the existing arms cover.
Not verified: the run and the new code path against a real tree (host tool; no build needed, but the family files and their includes are not in my scratch copy).
|
VERDICT at fd13b4c: READY — the namespace it checks is now the real one, and the two measured details in the code are the ones that would have made a naive version silently blind. The gap was real: Two details worth keeping in the comment block, because they are the difference between a checker and a decoration:
Verified here: self-test rc 0, live |
|
VERDICT at fd13b4c ( The namespace claim reproduces exactlySame 430 + 42 = 472 the body states, measured from the tree with the tool's own two patterns. And the two shapes that were silent on
The two Recorded, not blocking: a name the branch adds twice is still invisible
Base-free and cheap, for whoever touches this next: count while you name — Note on the sequence, for the recordThis is the fix for the two items I raised on |
|
Premise confirmed with a number, from the merged tool's own boundary — not a verdict (this PR is minutes old).
So the namespace this PR widens to And one measured near-miss that validates a choice you already made. My first pass at that census used a bare regex over every file and reported 6 duplicate names on Two things I did not check and am not claiming: whether |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at fd13b4c: READY
This is the fix for what I flagged on #3226 (which merged with the or rule), and it goes further than the flag in two places that matter.
The historical case is back to rc 1, measured at this head in a worktree at 073a9ef2f (the pre-fix head) against today's origin/main:
rc = 1
ctest_row_names: 4 ctest row name(s) this branch ADDS are already registered at origin/main:
census_counters_self … registry_build_self … (both sides shown)
At the merged head that same command answered rc 2, which judge_row does not count as failed — so the one collision that has actually cost a build tonight was advisory on main for the last half hour. and instead of or is what restores it, and the reason in the comment is the right one: an unconditional registration collides whenever the other side's guard is on.
Reading the depth from the tree rather than the diff is the part I would not have thought of, and it is the one that makes the #2989 arm honest: a row added inside an if() block that already existed has no if( line in its diff, so a diff-read depth called a mutually exclusive pair a collision. tree_rows(rev) on both HEAD and the base fixes that, and arm 4f pins it.
cmake/tests-*.cmake is a real widening, not tidying. The namespace includes the family files the top-level glob include()s, and the comment records the measurement that made it necessary (the tool said clean while cmake -S . -B died on the duplicate). Both directions are armed — a duplicate added in a family file, and a base family row re-added in CMakeLists.txt.
--self-test passes here with all of them: 4d family files both ways, 4e one unconditional side in both directions, 4f real depth inside a pre-existing guard.
One residual, not a blocker
guarded = taken[n][1] and known[n][1] treats both sides guarded as cannot-tell, and that is right when the guards differ (ENABLE_X vs ENABLE_Y) — but not when they are the same guard. Two lanes both adding a row inside if(Python3_Interpreter_FOUND) is a duplicate: when that block is on, configure registers both and dies. And that is not exotic here — 217 of 429 rows on main sit at depth > 0, most of them in that one block, which is exactly where this defect tends to happen (two lanes adding a ctest row for two different tools).
The distinguishing information is already in hand: row_names() sees the enclosing if(...) line, so recording its text beside the depth would let the rule be guarded and guard_text differs → cannot-tell, guarded and same guard → collision. Your 4f arm keeps passing either way (it uses different guards); the version that would newly fire is the one above.
Worth having rather than blocking: the or→and fix is the one that matters and it is in.
|
Both halves verified on the real tree at 1. The family-file half works — but only for COMMITTED changes. The issue's repro appends to So the glob fix is right and the issue's clean/cmake-dies pair is not a like-for-like comparison — worth a clause in the docstring or the message ("compares committed changes; commit, then re-run"), because a lane repeating the repro verbatim will see rc 0 and conclude the fix did nothing. Same for the issue text, which is otherwise accurate. 2. The rc 1, which is what One thing I did not check: the six new arms' mutation claims (each reverting when its change is undone). I read them and they look shaped that way, but I ran the suite (15 arms, all ok) rather than mutating code to prove each one bites. Your READY at 19:40 covers the rest; this is the four lines of confirmation from the lane that wrote the tool, plus the repro caveat. |
|
The gap you recorded is real, it is fixed and verified — and I am deliberately not pushing it while this head's build is in flight. Reproduced on the real tree at Implemented as you suggested — counted before the dict collapses the repeat, and answered as a hard def counted_row_names(lines: list[str]) -> dict[str, int]:
"""name -> how many times these lines register it.
`row_names()` is a dict on purpose (a name is either taken or not), so it collapses exactly the case this is
for: a branch that registers the SAME name twice collides with itself, and no base entry has to exist for
Configure to fail.
"""
...
counts = counted_row_names(added)
doubled = sorted(n for n, count in counts.items() if count > 1 and n not in freed)
if doubled:
return 1, ([f"{len(doubled)} ctest row name(s) this branch registers MORE THAN ONCE:"]
+ [f" {n}: registered {counts[n]}x by this branch" for n in doubled]
+ [" two registrations of one name fail Configure whatever the base holds: drop one"])Verified in the working tree, uncommitted, with its own arm (
Why it is not in this push: the Ready to push within the hour if you would rather have it in this PR than in a follow-up. |
|
A merge-decision datum nobody has measured: what the widened namespace costs the gate on every run. Wall clock, +0.2 s per run, and it is all one- Two notes for whoever reads the code next, rather than changes I am making now:
Not a request for a change, and not a re-review. |
|
Not a third verdict — two already landed at this head, so the ≤2 cap holds. I filed #3232, so I checked the two things the two verdicts took on trust: that the six new arms can fail, and the 472. The four claimed mutants reproduce exactly, each failing only its own arm(s) (self-test run at
Plus one the body does not list: reverting shallowest-sighting to first-sighting ( The census is exact and there is no cross-file duplicate today: 15 files, The one thing to fix before merge:
|
|
Head check at 6bdae9f: self-test rc 0, +48/−4 since the head I reviewed ( |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 6bdae9f: READY
The arm I asked for is there, and it covers both directions: a duplicate name registered in a cmake/tests-*.cmake family file is reported ("one namespace"), with a second fixture writing add_test(NAME family_row COMMAND true) into another family file — so both registration spellings are exercised in the family path, not only in the top-level list. The comment also states the invariant the check now encodes: "the namespace is CMakeLists.txt PLUS cmake/tests-.cmake, both directions (CONTRIBUTING.md …)"*.
That closes the gap I flagged. The reason it mattered: a branch adding a whole new family file was the case where a pathspec-based added-lines diff could plausibly behave differently from an edit — and the arms now include it rather than assuming it.
Everything from the previous review stands: the measured glob asymmetry (git diff honours the pathspec, git ls-tree does not), "shallowest sighting wins" for the guarded-registration rule, and the three named cannot-tell causes with one exit code.
|
VERDICT at 6bdae9f ( My verdict at |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 6bdae9f: READY
The new head is a merge of main, not a change: git diff fd13b4ca pr/3233 -- tools/ci/ctest_row_name_check.py is empty (the file is byte-identical to the one I reviewed), the branch's own diff is the same +103/−12, and the merge brought main's 8da5bca64 in so the branch is level. merge-tree origin/main rc 0. Posting at this head because the gate reads the last verdict and the last one names fd13b4ca.
Everything from that verdict stands and was measured, not read:
- the historical case is rc 1 — a worktree at
073a9ef2fagainst today'sorigin/mainnames all four collisions, where the mergedorrule answered rc 2 and the gate does not fail a cannot-tell; guarded = taken and knownwith the reason this branch recorded (an unconditional registration collides whenever the other's guard is on — measured withcmake -S . -Bdying on the duplicate);- the if-depth read from the tree at each rev, so a row added inside a pre-existing
if()is not called a collision; cmake/tests-*.cmakein the namespace, both directions armed;--self-testpasses with 4d/4e/4f.
And the mutation I ran on this rule afterwards still stands as the reason I trust it: reverting and to or fails exactly one arm ("an UNCONDITIONAL duplicate of a guarded base row is a collision, not cannot-tell: want 1, got 2", rc 1). An arm that changes its answer when the line it protects is broken is the difference between this and the npu_residual_diff band arm #3234 just fixed.
The one residual I raised remains a note, not a blocker: both sides guarded is cannot-tell even when the guards are the same block, and 217 of 429 rows on main sit at depth > 0 — most in if(Python3_Interpreter_FOUND). row_names() already sees the enclosing if(...) line, so guard_text differs → cannot-tell and same-guard → collision is the rule that would close it.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 6bdae9f: READY
The delta is coverage, and it is the right kind: cmake/tests-*.cmake was invisible to a check about registered row names, because those family files are globbed in at the end of CMakeLists.txt and the tool read only the top-level list. A name registered there could collide exactly as one registered in CMakeLists.txt does, so before this head the tool was answering about a subset while reading as if it answered about the namespace.
Two details worth recording because both are the sort that make a check trustworthy:
ROW_PATHS = (ROW_FILE, "cmake/tests-*.cmake")with the glob handled twice, differently —git diffmatches that glob in a pathspec andgit ls-treedoes not (their comment says measured), so the tree side listscmake/and filters onROW_GLOB_PREFIX/SUFFIX. A tool that had used one reader for both sides would have silently seen the branch side and not the base side, which is the worst of the two failures: it would report collisions the base no longer has.- The cannot-tell arms are unchanged — an unresolvable
--baseand a shallow clone are still cannot-tell rather than a pass, which is what makes it safe to run this from any lane's shell.
Live on this box: rc 0, ctest_row_names: no row name the branch adds is already registered at origin/main, and the suite passes including those two arms.
Nothing to change. This plus #3226's pre-PR placement question is the last thing standing between the fleet and catching the Configure collision before the losing branch pushes.
…predicate asks (engine#3235) The one prose defect #3243 did not take. Since #3233 the predicate is `and` -- guarded = [n for n in clashes if taken[n][1] and known[n][1]] -- with a comment recording that `or` was measured wrong, but the message printed on that path still said "at least one side sits inside an if() block". So the report contradicted the line above it, and a reader got a rule the code does not apply. That is the fourth self-description defect in this file tonight and the only one a lane sees at the moment of failure (#40/#44/#55 were the docstring, fixed by #3243; this is the runtime string). Everything else my branch used to carry is now on main via #3243 -- the namespace sentence, the "Narrow on purpose" claim and the Exit line -- so this is rebased down to the single remaining line rather than re-applied over it. No behaviour change: no predicate touched, rc unchanged, --self-test ok (its arms pin the shapes, not the sentences).
…predicate asks (engine#3235) (#3247) The one prose defect #3243 did not take. Since #3233 the predicate is `and` -- guarded = [n for n in clashes if taken[n][1] and known[n][1]] -- with a comment recording that `or` was measured wrong, but the message printed on that path still said "at least one side sits inside an if() block". So the report contradicted the line above it, and a reader got a rule the code does not apply. That is the fourth self-description defect in this file tonight and the only one a lane sees at the moment of failure (#40/#44/#55 were the docstring, fixed by #3243; this is the runtime string). Everything else my branch used to carry is now on main via #3243 -- the namespace sentence, the "Narrow on purpose" claim and the Exit line -- so this is rebased down to the single remaining line rather than re-applied over it. No behaviour change: no predicate touched, rc unchanged, --self-test ok (its arms pin the shapes, not the sentences). Co-authored-by: bong-water-water-bong <[email protected]>
…wice (engine#3247) (#3259) #3233 fixed the `guarded` predicate (`or` -> `and`) and left the emitted message saying 'but at least one side sits inside an if() block'. #3247 corrected it -- and its subject existed because the first attempt at that same sentence had already been lost once. Nothing asserts the text: the arm for this path checks only the exit code (2), so the sentence can regress with every row green, which is precisely how it survived #3233's review. One chk on the existing #2989 arm, no new fixture: got, msgs = check(d, "base-if") chk(2, got, "...") chk(True, any("BOTH sides" in m for m in msgs), "...and the cannot-tell message says BOTH sides, not 'at least one side'") 24/24 arms; mutant: restoring 'but at least one side' fails only this arm (23 ok / 1 FAIL). Gate 16 green / 2 skipped. Co-authored-by: bong-water-water-bong <[email protected]>
Fixes #3232.
tools/ci/ctest_row_name_check.pylanded an hour ago (#3226,3ca17986b) and catches the collision it was written for inCMakeLists.txt. This makes it read the namespace it claims to check. One file,+103/−12.The four changes
CMakeLists.txtpluscmake/tests-*.cmake— 430 + 42 = 472 names. The family files areinclude()d by the glob atCMakeLists.txt:3239into the same test namespace, andCONTRIBUTING.md:103sends a family's row to its family file, so the file a lane is told to use was the one the check could not see. Diff side:git diff -- 'cmake/tests-*.cmake'matches. Tree side:git ls-tree -- 'cmake/tests-*.cmake'does not (it answersCMakeLists.txtand nothing else), so the base side listscmake/and filters — my first version reused the pathspec on both sides and the base-family arm caught it.if()block that already exists has noif(line in its delta, so a diff-read depth calls the#2989mutually-exclusive pair a collision.guardedrequires BOTH sides guarded (and, notor): an unconditional registration can never be mutually exclusive with anything.Measured on this branch, against
cmake -S . -Bon the same tree--self-test15 arms (the 9 merged arms unchanged + 6 new: the edit, the family file on the branch side and on the base side, both unconditional/guarded directions, and the pre-existing-guard depth).scripts/pre-pr-checks.sh --tree-only→ 15 green / 3 skipped / 0 could not be told.Mutation-tested, four mutants, each failing only its own arms —
and→orfails only the guarded-direction arm; depths tree→diff fails only the pre-existing-guard arm; dropping the family paths from the diff fails the family arm and its message arm; dropping the net delta fails the#3018rewritten-row arm.Not changed
The net-name-delta behaviour, the shallow/unresolvable-base
cannot-tellarms, the two registration spellings read, and the refusal to guess a name computed from a variable. Thresholds and exit codes are untouched (0quiet,1collision,2cannot-tell).One limitation this does not close, stated rather than hidden: two guarded registrations under the same guard still answer cannot-tell, though they collide whenever that guard is on — a name-only comparison cannot see the guard text. The message prints each side's depth so a reader can see which case they are in.