Skip to content

ctest_skips: --root defaults to the repo, not the caller's cwd (a wrong root reads as a broken baseline) - #2749

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-game/ctest-skips-root
Nov 16, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-game/ctest-skips-root

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs #2730 (that issue closed in #2736, which wired ctest_skips.py --log into CI; this is the footgun the wiring exposed).

The defect

tools/ci/ctest_skips.py's --root defaulted to "." — the caller's cwd. Every sibling tool in this repo (registry_build.py, merged_tail_check.py) resolves its root from __file__, because a tool that reads "the tree I am in" answers differently depending on where you stand.

The row #2736 added runs at the repo root, where "." happens to be right, so CI was never wrong. Run by hand from anywhere else, the tool reads a stranger's baseline and reports every skipped test as unbaselined:

$ cd /  &&  python3 <repo>/tools/ci/ctest_skips.py --log <a real 375-test CI log>
ctest_skips: amdxdna_restart SKIPPED and the baseline does not name it -- ...
... 16 such lines ...                                                                     rc 1

That output is indistinguishable from a genuinely broken baseline — which is exactly how I misread it while wiring #2736, for long enough to believe #2726 had failed to merge.

The change

TOOL_ROOT = pathlib.Path(__file__).resolve().parents[2]   # tools/ci/ctest_skips.py -> repo root
ap.add_argument("--root", default=str(TOOL_ROOT),
                help="the tree that holds %s (default: the repo this tool ships in, never the caller's cwd)" % BASELINE)

The parser is extracted as _parser() so the default is testable — otherwise this fix would ship with no arm, which is the defect this repo has a policy about. One new arm:

ok   with no --root the baseline is the repo's own, so a run from another cwd cannot read a stranger's

Measured

On a real 375-test CI log with 16 skips:

cwd=/ , no --root, before this PR:   16x "does not name it"                        rc 1
cwd=/ , no --root, after  this PR:   "16 of 375 test(s) did not run, all named in the baseline"   rc 0
cwd=repo root, after this PR:        same answer                                    rc 0

Mutant, so the arm is shown to fire: setting the default back to "." makes --self-test FAIL with

FAIL with no --root the baseline is the repo's own, so a run from another cwd cannot read a stranger's

--self-test is 12/12 with the fix, scripts/pre-pr-checks.sh 12 green / 3 skipped, git diff origin/main is this one file (+14/−3).

Opened as a draft: engine had 8 non-draft open PRs against the cap of three at 19:18Z, and a draft runs the same build, so it undrafts on green rather than adding a merge-eligible row now.

…e#2730)

The row this PR adds runs at the repo root, where "." happens to be right. Run by hand from
anywhere else it read a stranger's baseline and reported all 16 skipped tests as unbaselined --
a wrong --root is indistinguishable from a broken baseline, which is how I misread it for a
while. Every sibling tool resolves its root from __file__ for this reason.

Parser extracted as _parser() so the default is testable; the new arm fails when the default
goes back to ".".

Measured with a real 375-test CI log (16 skips):
  cwd=/ , no --root   before: 16x 'does not name it', rc 1     after: 'all named in the baseline', rc 0
  mutant (default='.')  self-test FAILS on the new arm
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 4665205: READY. The default is fixed the way the family does it, the arm asserts the value rather than the help text, and the reason is stated in one line that is worth keeping verbatim. One symmetric half is left: an explicit --root pointing at the wrong tree still reads exactly like a broken baseline.

What is right

TOOL_ROOT = pathlib.Path(__file__).resolve().parents[2]
ap.add_argument("--root", default=str(TOOL_ROOT),
                help="… (default: the repo this tool ships in, never the caller's cwd)")
  • The same convention as the siblings (registry_build.py, merged_tail_check.py resolve from __file__), so the tool family has one answer to "which tree am I reading" instead of one per tool — which is the rule that keeps them from disagreeing about a pin.
  • The arm pins the default's value, not that the flag exists: parse_args([]).root == str(TOOL_ROOT), with the reason on the line — "so a run from another cwd cannot read a stranger's".
  • The defect statement is the most useful sentence in the PR: "a wrong --root looked exactly like a broken baseline." That is the whole class — a configuration mistake indistinguishable from a data problem — and it is why the fix is worth more than the line it changes.

The ask: baseline() still treats a missing file as an empty baseline

def baseline(root):
    path = root / BASELINE
    out = {}
    if not path.is_file():
        return out          # ← an absent baseline and an empty one answer identically

So --root /tmp/somewhere — the explicit form, which is exactly what a reader reaches for after reading the new help text — produces an empty baseline, and every skip in the log is then reported as "SKIPPED and the baseline does not name it": a NEW skip, exit 1. The default is now safe; the flag is the remaining way to reach the same misleading state.

The fix is the distinction the tool already draws elsewhere in the same file ("cannot tell: the log has no 'N% tests passed' summary line" → return 2):

ctest_skips: cannot tell: no baseline at <root>/tools/ci/ctest_skips.txt
             (--root names <root>; the baseline lives in the repo this tool ships in)
  → exit 2

An absent baseline is "I cannot judge", never "all of these are new" — the same split #2733 is asking for between an unset GPU_KERNELS_DIR and one set to a non-tree, and the same one #2610 settled for attributed.log. Three tools, one rule: an absence the tool can see must not be reported as a finding about the data.

What I checked and did not

  • Checked: the default's derivation and its arm, the sibling convention, and that baseline() returns {} for a missing file — so the explicit---root path still reaches the misleading output.
  • Not checked: the --log parsing itself. That is #2730's subject and #2736's wiring; this review is about the root, and the two should not be one decision.

@bong-water-water-bong
bong-water-water-bong marked this pull request as ready for review November 16, 2026 19:38
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Undrafted — build passed (18m33s) before the undraft, so this adds no run to the queue; the draft was only ever blocking merge eligibility. Two things worth knowing when reviewing:

  1. The arm is the load-bearing part. Revert default=str(TOOL_ROOT) to default="." and --self-test fails on exactly one arm (FAIL with no --root the baseline is the repo's own, so a run from another cwd cannot read a stranger's). Without that arm this fix would be a silent-wrong-answer change with no evidence — the class the repo has a policy about.
  2. Why this is not noise: the row ci: run ctest_skips --log on the Test step's own log, so a suite that skipped to green stops reading as green (engine#2730) #2736 added runs at the repo root where "." is right, so CI never showed the bug. It only bites a person or an agent running the tool by hand from anywhere else, and it looks exactly like a broken baseline — which cost me a false alarm while wiring ci: run ctest_skips --log on the Test step's own log, so a suite that skipped to green stops reading as green (engine#2730) #2736.

@bong-water-water-bong
bong-water-water-bong merged commit 490fc8f into main Nov 16, 2026
9 of 11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-game/ctest-skips-root branch November 16, 2026 19:50
bong-water-water-bong added a commit that referenced this pull request Nov 16, 2026
…e's header (engine#2750) (#2756)

--write is the documented way to maintain the baseline, and it did two things that let the check be
satisfied without evidence: it baselined a new skip as '# TODO: why this cannot run here' and the
check then passed, and it regenerated the file from three hard-coded lines, so the Apache notice
every engine file carries disappeared after one run.

Now a NEW name requires --reason; existing entries keep the reason they already carry, so the
routine refresh is still one command; and the leading comment block is preserved verbatim.

Measured on a real 375-test CI log: a new skip without --reason -> rc 1, nothing written, the test
named on stderr; with --reason -> the caller's reason is recorded; the licence header survives.
Mutants: dropping the --reason requirement fails 4 arms, regenerating the header fails 1.

Held un-pushed while engine#2749 (same file) is open -- two open PRs to one file is the case
two-open-prs-one-file warns about. Lands on top of #2749 once it merges.

Co-authored-by: bong-water-water-bong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant