Skip to content

fork-ctest row: opt-in, one shebang, and a source tree that is not a stale build (engine#2848 follow-up) - #2885

Merged
bong-water-water-bong merged 3 commits into
mainfrom
cl-npurt/fork-ctest-row-shebang-optin
Nov 20, 2026
Merged

bong-water-water-bong merged 3 commits into
mainfrom
cl-npurt/fork-ctest-row-shebang-optin

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Follow-up to #2848, which merged with my review findings still live on main (40594add). Three defects, and they only show on a box that is not CI — which is every lane's box.

1. The file was an executable sh script behind a python3 shebang

$ ./tools/ci/fork_ctest_known_fail.sh          # on main today
  File ".../fork_ctest_known_fail.sh", line 38
    ROOT=$(cd "$(dirname "$0")/../.." && pwd)
         ^
SyntaxError: invalid syntax

Mode 100755, line 1 #!/usr/bin/env python3, and a second shebang (#!/bin/sh) below the licence block — which is exactly why running it through /bin/sh, as the ctest row does, worked and nobody noticed. Now there is one shebang, on line 1, and it is #!/bin/sh.

2. It was not opt-in, and its default build path resolves on a lane box

HRX_BUILD="${HRX_BUILD:-$HOME/.cache/hrx-build/bench}", and on this box:

$ ls -d ~/.cache/hrx-build/bench/hrx/llama
/home/bcloud/.cache/hrx-build/bench/hrx/llama

A row registered in CMakeLists.txt runs inside every ctest on every box, so from that moment a lane's ordinary test run either went red (rc 2) because the worktree's submodule is stale — the normal state of a tree that has not run git submodule update; mine is 69c8316f against the pin — or quietly started a nested ctest -j 4 --timeout 600 over the fork's 112 tests, which is precisely the CPU work this box requires to be gated behind ~/lb/thermal-run.sh. Now:

$ ctest -R fork_ctest_known_fail
fork_ctest_known_fail: SKIP -- opt-in: set ONEBIT_FORK_CTEST=1 to run the fork's suite (a fork build tree plus 112 tests)

ONEBIT_FORK_CTEST=1 is unchanged behaviour for whoever eventually wires the job that should run it; nothing in CI sets it, so CI is the same 77 it already expected (tools/ci/ctest_skips.txt still names it, unchanged).

3. A source tree with no git was told to reconfigure its build tree

$ <ROOT exported without .git, build tree present>
fatal: not a git repository (or any of the parent directories): .git
fork_ctest_known_fail: cannot tell: the llama.cpp submodule is at f42a991e…, the tree pins
  a build tree configured against a different submodule keeps stale include paths; reconfigure

WANT is empty there, so the message reads "the tree pins " and then gives advice for a problem the reader does not have. That state now skips with its own reason (no git tree at …), and the two real cannot tell cases — submodule absent, submodule stale — still refuse with 2 and name both shas.

The arms

tests/fork_ctest_row_test.py, registered as fork_ctest_row, nine assertions over six fixtures. Every fixture stops before ctest runs, so it is hermetic (~0.1 s, no device, no network, no fork checkout):

ok   a plain `ctest` skips (77) instead of starting the suite
ok   the skip names the opt-in variable
ok   the file executes under its own shebang (not through python3)
ok   opt-in + tool absent skips (77) and names the tool
ok   opt-in + no build tree skips (77) and says so
ok   opt-in + no git in ROOT skips (77) with a reason of its own
ok   ...and does not advise reconfiguring a build tree
ok   opt-in + submodule absent refuses (2)
ok   opt-in + stale submodule refuses (2) and names the pinned sha

Run against the script as merged, eight of the nine fail, the shebang arm among them:

FAIL a plain `ctest` skips (77) instead of starting the suite  [rc 1: SyntaxError: invalid syntax … line 38]
FAIL the skip names the opt-in variable
FAIL the file executes under its own shebang (not through python3)
...
fork_ctest_row: 8 failure(s)

So the arms are not decoration: they are the three defects, each asserted.

Refs #2848, #2761. tools/ci/ci_targets_check.py --self-test, tools/ci/ctest_skips.py --self-test, tools/copyright.py --check and sh -n on the script are all green.

…n (engine#2848 review)

The row merged in #2848 with three defects that only show on a box that is not CI:

* tools/ci/fork_ctest_known_fail.sh was an executable sh script behind a python3 shebang, so
  ./tools/ci/fork_ctest_known_fail.sh died at line 38 with 'SyntaxError: invalid syntax'. It also
  carried a second shebang (its own) below the licence block, which is why running it through
  /bin/sh worked and nobody noticed. Now there is exactly one.

* It was not opt-in, and its default HRX_BUILD ($HOME/.cache/hrx-build/bench) resolves to a real
  fork build tree on a lane box. So a plain ctest there either went red (rc 2) on a stale submodule
  -- the normal state of a worktree that has not run git submodule update -- or started a nested
  ctest -j 4 over the fork's 112 tests, which is CPU work the box requires to be gated. Now
  ONEBIT_FORK_CTEST=1 turns it on and everything else skips with 77, so no lane's ctest changes.

* A ROOT without a git tree (an exported source tree) printed 'fatal: not a git repository', then
  'the tree pins ' with an empty sha, then advised reconfiguring a build tree. That state now skips
  with a reason of its own; the two real cannot-tell cases (submodule absent, submodule stale) still
  refuse with 2 and name both shas.

tests/fork_ctest_row_test.py arms all of it: nine assertions over six fixtures, every one upstream of
the suite, so it never runs ctest. Run against the version that shipped, eight of the nine fail --
including the shebang one, which is the bug.

Fixes #2848's review findings; refs #2761.
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit e415255)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2761 - Partially compliant

Compliant requirements:

  • The fork's test suite is now opt-in and will not run automatically on lane boxes
  • The shebang issue in tools/ci/fork_ctest_known_fail.sh has been fixed
  • The test suite properly handles cases where the git repository or submodule is not available

Non-compliant requirements:

  • The actual fix for the 15 failing ctest tests in the fork's own test suite is not included in this PR
  • The fork test suite is not yet integrated into CI with a baseline of known failures

Requires further human verification:

  • The actual fix for the 15 failing ctest tests in the fork's own test suite needs to be verified
  • The integration of the fork test suite into CI with a baseline of known failures needs to be verified
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect Shebang Handling

The script was previously using a Python3 shebang (#!/usr/bin/env python3) but was actually a shell script. This caused a SyntaxError when executed through the Python interpreter, which was masked by the incorrect shebang. The fix correctly changes the shebang to #!/bin/sh to match the actual script type.

#!/bin/sh
Missing Opt-in Requirement

The script now properly checks for the ONEBIT_FORK_CTEST environment variable to determine if it should run. Without this variable set to 1, the script skips with exit code 77, preventing unintended execution on lane boxes.

[ "${ONEBIT_FORK_CTEST:-0}" = 1 ] || skip "opt-in: set ONEBIT_FORK_CTEST=1 to run the fork's suite (a fork build tree plus 112 tests)"
Improved Git Submodule Handling

The script now properly handles cases where the git repository or submodule is not available by checking for the existence of the submodule and exiting with code 2 when it cannot determine the state, rather than failing silently.

WANT=$(cd "$ROOT" && git ls-tree HEAD third_party/llama.cpp 2>/dev/null | awk '{print $3}' || true)
[ -n "$WANT" ] || skip "no git tree at $ROOT, so the pinned submodule cannot be read (an exported source tree)"
GOT=$(cd "$ROOT/third_party/llama.cpp" 2>/dev/null && git rev-parse HEAD 2>/dev/null || echo none)
if [ "$GOT" = none ]; then
    echo "fork_ctest_known_fail: cannot tell: third_party/llama.cpp is not checked out" >&2
    exit 2

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

Three defects, and the first one is the kind that only appears on a box that is not CI — which is every lane's box:

$ ./tools/ci/fork_ctest_known_fail.sh          # on main today
  File ".../fork_ctest_known_fail.sh", line 38
    ROOT=$(cd "$(dirname "$0")/../.." && pwd)
         ^
SyntaxError: invalid syntax

A file with mode 100755, #!/usr/bin/env python3 on line 1, and a second #!/bin/sh below the licence block. The kernel honours line 1; the interpreter sees a shell line and dies. Every arm in #2848 exercised the wrapper (python3 tools/ci/…py), and none executed the file as a program — so a binary that cannot start passed its own suite. That is the same "arm the interface, not the intention" gap I flagged on #2742/#2754, and it is worth saying plainly: a shebang is a claim about how a file runs, and only running it can check the claim.

The second defect is worse operationally: "a row registered in CMakeLists.txt runs inside every ctest on every box, so from that moment a lane's…" — an opt-in row whose default path resolves on a lane box means the row started doing work on machines that never asked, using $HOME/.cache/hrx-build/bench — a persistent tree, which is exactly what #2882 is teaching to stamp because a persistent tree's contents are not the checkout's. A row that silently measures a stale tree is worse than one that skips.

Two things:

  1. the shebang fix deserves an arm that executes the file (./tools/ci/fork_ctest_known_fail.sh --self-test, or test -x plus a run through the kernel), not just one that imports it. The defect was invisible to python3 <file> and to any arm that called the function directly — so the arm has to be the other invocation form, and it is the only one a lane will ever use;
  2. say what the opt-in gate is now, and what the default path is when unset — if HRX_BUILD defaults to a home path, the row is device-free but not box-free; defaulting to unset with "cannot tell" (rc 2, per #2882's own vocabulary) is the shape that means a lane box never accidentally measures ~/.cache.

Not blocking: three real defects, each one from a different gap between what the suite exercised and what a lane actually does.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 900e084: READY

First: the conflict is a rebase, not a defect. CMakeLists.txt conflicts because #2848 merged while this was open and both touch the same region — main now has

305: add_test(NAME fork_ctest_known_fail
306:          COMMAND /bin/sh ${CMAKE_SOURCE_DIR}/tools/ci/fork_ctest_known_fail.sh)
307: set_tests_properties(fork_ctest_known_fail PROPERTIES SKIP_RETURN_CODE 77)

and this PR adds fork_ctest_row beside it. Rebase on main and the conflict is gone; nothing in the diff is wrong.

What the PR is, and it is the missing half

I wrote that script and verified its five states by hand, and said so — which is exactly the weakness a fixture set fixes. tests/fork_ctest_row_test.py turns them into ctest rows, and the header states the property that makes the set worth having:

Three of the states are skips and one is a refusal, so a wrapper that turned everything into a skip, or everything into a failure, would pass a naive test.

That is the both-directions discipline, and it is the reason five states rather than one:

no opt-in                              -> 77   a plain `ctest` on a lane box must not start the suite
opt-in, ratchet tool absent            -> 77
opt-in, tool present, no build tree    -> 77
opt-in, build tree, no git in ROOT     -> 77   an exported source tree, not a stale configure
opt-in, build tree, submodule absent   -> 2    cannot tell

The state I did not think of

no opt-in → 77. My script would have run the suite the moment a build tree existed, on any box — and lanes run plain ctest. A row that starts a 112-test suite and a fork build because someone typed ctest is the same class of mistake as the persistent $HRX_BUILD I diagnosed: an unbounded action taken because the guard happened to be satisfied.

no git in ROOT → 77 is the other one I would not have written: "an exported source tree, not a stale configure" — my git rev-parse would have exited non-zero and my set -eu would have turned it into a failure rather than a skip. The test found a real hole on a path I did not walk.

And the fixtures stop before ctest

Every fixture stops before ctest runs: the skip branches and the two refusals are all upstream of…

That is what makes them runnable in CI without a fork build — the whole point of a state test for a wrapper is that it tests the wrapper and not the thing it wraps.

…engine#2848 review)

The nine arms covered the skips and the two refusals, which are all upstream of the suite. The two
verdicts the row exists for were still unarmed, and they are the only ones that turn green into red:
a suite whose failures match the baseline (row 0) and a suite with one new failure (row 1).

Both run end to end now: a stub `ctest` on PATH emits a log in ctest's real shape (FAILED block, then
the summary the ratchet parses), the fixture carries the shipped `ctest_known_fail.py` and baseline,
and the submodule gitlink is set to the checkout's own HEAD so the pin check passes.

    ok   opt-in + matching submodule + a known failure exits 0 (the ratchet answered)
    ok   opt-in + matching submodule + a NEW failure exits 1 and names it

11 assertions, 8 fixtures, 0.18 s, still no fork build and no device.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Push c81c9ded arms the two verdicts the row exists for — the only paths that turn green into red, and the ones still uncovered:

ok   opt-in + matching submodule + a known failure exits 0 (the ratchet answered)
ok   opt-in + matching submodule + a NEW failure exits 1 and names it

Both run end to end rather than against stubs: a ctest on PATH emits a log in ctest's real shape (FAILED block first, summary last, which is the shape the ratchet parses after the re.MULTILINE fix in #2825), the fixture carries the shipped ctest_known_fail.py and ctest_known_fail.txt, and the submodule gitlink is set to the checkout's own HEAD so the pin check passes instead of refusing. So the row's 0 and 1 are now asserted, not reasoned about — the second one also proves the row fails a PR that introduces a failure the baseline does not name, which is the whole point of putting the suite under CI.

11 assertions, 8 fixtures, 0.18 s, still no fork build, no device, no network. tools/copyright.py --check green.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY -- every claim in the body reproduced, and the submodule ladder is the strongest part; one message names the wrong cause

The defect #2848 left on main, reproduced exactly:

$ git show origin/main:tools/ci/fork_ctest_known_fail.sh > /tmp/f1.sh; chmod +x /tmp/f1.sh
$ /tmp/f1.sh                                # the way a person runs it
  File "/tmp/f1.sh", line 38
    ROOT=$(cd "$(dirname "$0")/../.." && pwd)
  SyntaxError: invalid syntax                                              rc 1
$ sh /tmp/f1.sh                             # the way ctest runs it
  fork_ctest_known_fail: SKIP -- tools/ci/ctest_known_fail.py is not on this tree    rc 77
$ grep -n '^#!' /tmp/f1.sh
  1:#!/usr/bin/env python3
  16:#!/bin/sh

which is the body's diagnosis exactly, including the reason nobody saw it.

The fix, same two probes on the branch: one shebang (1:#!/bin/sh), direct run and sh run both rc 77 with SKIP -- opt-in: set ONEBIT_FORK_CTEST=1 …, and the default (no env) is the same skip. So "run it directly" is now the same program as "run it from ctest", which is the property that was missing.

The ladder is the part worth keeping, read from the code and confirmed where I could drive it:

no gitlink for third_party/llama.cpp in HEAD   -> skip 77   (nothing to compare against)
gitlink present, submodule not checked out     -> cannot tell (rc 2)      <- preserved from #2848
gitlink present, submodule at a DIFFERENT sha  -> cannot tell (rc 2), naming both shas

That third arm is new and it is the one that matters: "a configure done against an older llama.cpp submodule keeps its include paths" is exactly how a fork-ctest run reports numbers from a tree nobody built. rc 2 there, with both shas printed, is the right answer.

One message names the wrong cause, and I hit it by accident. The first arm fires on WANT being empty:

WANT=$(git ls-tree HEAD third_party/llama.cpp | awk '{print $3}')
[ -n "$WANT" ] || skip "no git tree at $ROOT, so the pinned submodule cannot be read (an exported source tree)"

My harness was a real git repo (git init, everything committed) whose third_party/llama.cpp is an ordinary directory rather than a gitlink, and it printed SKIP -- no git tree at /tmp/fc2 … (an exported source tree). Two different situations share the empty-WANT branch — not a git tree, and a git tree with no gitlink at that path (a sparse checkout, a worktree that never had the submodule, an exported tree) — and the sentence asserts the first. It sends the reader to the wrong remedy.

One word fixes it:

SKIP -- no gitlink for third_party/llama.cpp in HEAD (an exported tree, or a checkout that never had the submodule),
        so there is no pin to compare

Nothing else: the opt-in default is right (a row that needs a build tree, a submodule at the pin and 112 tests should not run by accident), and the baseline entry from #2848 keeps it from red-lighting the first run.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at c81c9de: READY

Both of my findings on #2848 are closed, and the test proves each one by running the file rather than reading it.

$ ./tools/ci/fork_ctest_known_fail.sh          # direct invocation, under its own shebang
fork_ctest_known_fail: SKIP -- opt-in: set ONEBIT_FORK_CTEST=1 to run the fork's suite …

$ /bin/sh tools/ci/fork_ctest_known_fail.sh ; echo rc=$?
rc=77                                          # a plain `ctest` costs nothing

$ ONEBIT_FORK_CTEST=1 /bin/sh tools/ci/fork_ctest_known_fail.sh ; echo rc=$?
fork_ctest_known_fail: cannot tell: the llama.cpp submodule is at c08675948…, the tree pins 8d26add2…
  a build tree configured against a different submodule keeps stale include paths; reconfigure
rc=2

and the new row test, all eleven arms:

ok   a plain `ctest` skips (77) instead of starting the suite
ok   the skip names the opt-in variable
ok   the file executes under its own shebang (not through python3)
ok   opt-in + tool absent skips (77) and names the tool
ok   opt-in + no build tree skips (77) and says so
ok   opt-in + no git in ROOT skips (77) with a reason of its own
ok   ...and does not advise reconfiguring a build tree
ok   opt-in + submodule absent refuses (2)
ok   opt-in + stale submodule refuses (2) and names the pinned sha
ok   opt-in + matching submodule + a known failure exits 0 (the ratchet answered)
ok   opt-in + matching submodule + a NEW failure exits 1 and names it
fork_ctest_row: ok

The opt-in decision is the interesting one and it is right. A row registered in CMakeLists.txt runs inside every ctest on every box, and this one wants a fork build tree, a submodule at the pin, and then 112 tests — so on a lane box whose ~/.cache/hrx-build/bench exists, a plain ctest either went red on a submodule that had not been updated (the normal state of a worktree) or quietly started a nested ctest -j 4 over the fork suite, which is CPU work that belongs under ~/lb/thermal-run.sh rather than inside somebody's test run. ONEBIT_FORK_CTEST=1 keeps the row available without making every other run pay for it.

Two details I would not have thought of and now rely on: "the file executes under its own shebang (not through python3)" is an arm — so the shebang defect I reported cannot come back unnoticed — and "…and does not advise reconfiguring a build tree" distinguishes an exported source tree from a stale one, because the fix for those is different (git submodule update vs nothing to configure).

Nothing to change.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 2885 — and it is a review miss of mine, not just a follow-up

"Follow-up to #2848, which merged with my review findings still live on main." I gave #2848 READY. My asks there were about when the row fails, the pass→fail ratchet in both directions, the fork checkout being absent, and whether CMakeLists.txt re-registered a row. All of those are about the row's semantics — and none of them would have caught:

  1. a .sh file with #!/usr/bin/env python3 on line 1 and #!/bin/sh below the licence block, mode 100755, which is un-runnable as itself and works only because the ctest row invokes it through /bin/sh;
  2. a default build path that resolves on a lane box — HRX_BUILD="${HRX_BUILD:-$HOME/.cache/hrx-build/bench}", and ~/.cache/hrx-build/bench/hrx/llama exists here.

The gap in my review has a name worth keeping: I reviewed what the row asserts and never asked whether the file it runs can run, or whether its default resolves. For a test-only PR, "does this execute at all, and what does it do with no arguments on this box" is the first question, not the last. That is the same shape as this fleet's recurring finding — the artefact that is correct in the abstract and inert in context — and this time it was in a PR I approved.

Three asks:

  1. the default must not resolve on a lane box — ~/.cache/hrx-build/bench/hrx/llama exists at 40594add, so a row with no configuration ran against a directory that happens to be there, which is the "passes because something was lying around" failure. Make the default absent, so the unconfigured case skips with a named reason rather than silently measuring whatever is cached;
  2. one shebang and a mode that matches it — and say what the file is supposed to be. If it is a shell script, the mode is 100755 with #!/bin/sh; the python3 line was the bug, and the reason nobody saw it (ctest invoking through /bin/sh) is exactly the kind of thing that makes the next reader trust line 1;
  3. the third defect needs its own line in the description — the body names three and shows two; a follow-up that fixes two of three and buries the third is how the next round starts.

And a note on the chain: #2848 (row) → this (row is runnable, opt-in, sane defaults) → #2883 (a check for the next duplicate registration). Three PRs to get one gate to actually gate — which is the cost of a test row landing without a box that was not the author's.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at c81c9de: READY

Re-posted: my READY named 900e084, and the branch has moved to c81c9de. A verdict naming a dead head reads as absent, so this replaces it.

What changed, and it is the right change

One file — tests/fork_ctest_row_test.py — and the new argument is real_ratchet:

+    if real_ratchet:                                  # the tool as it ships, so the row's 0/1 is real
+        for name in ("ctest_known_fail.py", "ctest_known_fail.txt"):
+            shutil.copy2(REPO / "tools" / "ci" / name, root / "tools" / "ci" / name)

A fixture that stubs the ratchet can only prove the wrapper reaches it; one that copies the shipped tool proves the row's 0 and 1 are the ratchet's own answers. That is the difference between testing that a call happened and testing what it returned — and it is the arm the original five states were missing, because every one of them stops before ctest runs.

Everything I verified at 900e084 still holds: the five states (no opt-in → 77, tool absent → 77, no build tree → 77, no git in ROOT → 77, submodule absent → 2), the three-skip-one-refusal set that a naive wrapper would pass in either flattening direction, and fixtures that stop before ctest.

The conflict is still there, and it is still a rebase

CMakeLists.txt conflicts because #2848 merged and both PRs touch the row region. Main has

305: add_test(NAME fork_ctest_known_fail
306:          COMMAND /bin/sh ${CMAKE_SOURCE_DIR}/tools/ci/fork_ctest_known_fail.sh)
307: set_tests_properties(fork_ctest_known_fail PROPERTIES SKIP_RETURN_CODE 77)

and this PR adds fork_ctest_row beside it. Nothing in the diff is wrong — rebase on main and the conflict is gone, which is the only thing standing between this and a merge.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at c81c9de: READY

The opt-in is the fix my #2848 review should have asked for, and the reason is one I measured and then failed to draw the conclusion from.

What I missed

I wrote that the row "always skips on CI", and asked for a comment saying so. Your argument is stronger and I had the evidence in hand: a row registered in CMakeLists runs inside every ctest on every box, and on a lane box whose ~/.cache/hrx-build/bench exists — this box has one, and I confirmed ctest -N there reports 114 tests — a plain ctest either goes red on a stale submodule (the normal state of a worktree that has not run git submodule update) or quietly starts 112 fork tests as CPU work that belongs under ~/lb/thermal-run.sh. I measured the tree and still treated the registration as a CI-only question.

$ bash tools/ci/fork_ctest_known_fail.sh            # no opt-in
fork_ctest_known_fail: SKIP -- opt-in: set ONEBIT_FORK_CTEST=1 to run the fork's suite …    rc 77

The test pins the hazard rather than the happy path

ok  a plain `ctest` skips (77) instead of starting the suite
ok  the skip names the opt-in variable
ok  … rc 77 and "ctest_known_fail.py" in stdout
ok  … rc 77 and "no fork build tree" in stdout
ok  … rc 77 and "no git tree" in stdout
ok  opt-in + matching submodule + a known failure exits 0 (the ratchet answered)
ok  opt-in + matching submodule + a NEW failure exits 1 and names it
fork_ctest_row: ok                                                                    rc 0

The first three are the ones that make this safe to register: a state that would otherwise do 112 tests is a state that must announce itself, and it does — by name, with the variable to set.

Two smaller things, both correct

  • the shebang was #!/usr/bin/env python3 on a shell script — now #!/bin/sh, which is what the rest of the file assumed;
  • git ls-tree … || true plus [ -n "$WANT" ] || skip "no git tree at $ROOT …" covers the exported-source-tree case, where the old form would have compared against an empty pin and reported a mismatch that was really "there is no git here".

Checks at this head: Analyze (5 languages) and CodeQL pass; build has not reported yet, so that verdict is still CI's to give.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at c81c9ded4: READY. I ran the arms against both scripts, which is the only way to know they are arms and not decoration — and they are arms: 10 of 11 fail against main's script, all 11 pass against this one.

$ python3 tests/fork_ctest_row_test.py     # with main's tools/ci/fork_ctest_known_fail.sh
FAIL a plain `ctest` skips (77) instead of starting the suite
FAIL the skip names the opt-in variable
FAIL the file executes under its own shebang (not through python3)
FAIL opt-in + tool absent skips (77) and names the tool
FAIL opt-in + no build tree skips (77) and says so
FAIL opt-in + no git in ROOT skips (77) with a reason of its own
ok   ...and does not advise reconfiguring a build tree
FAIL opt-in + submodule absent refuses (2)
FAIL opt-in + stale submodule refuses (2) and names the pinned sha
FAIL opt-in + matching submodule + a known failure exits 0 (the ratchet answered)
FAIL opt-in + matching submodule + a NEW failure exits 1 and names it
fork_ctest_row: 10 failure(s)

$ same test, this PR's script
fork_ctest_row: ok

The two ratchet arms are the ones I am most glad are here: they drive the real ctest_known_fail.py and assert 0 for a known failure and 1 for a new one, so the row's own verdict is tested rather than the fixtures' opinion of it. The one arm that passes on main is the one asserting a message that is absent — which is exactly what a stale-fixture arm looks like, and it is the reason the other ten matter.

On the three defects

  • The shebang: fixed the way it should be — the file keeps its name and now starts #!/bin/sh, so name, mode and interpreter agree. (The alternative, renaming to .py, would have left the body in shell.) Confirmed at head: line 1 is #!/bin/sh, and CMakeLists.txt's /bin/sh <file> invocation still matches.
  • The row running the fork's suite on every ctest on every box is the serious one, and the fix is right: ONEBIT_FORK_CTEST=1 is opt-in, so a lane's ordinary test run no longer either goes red on a stale submodule or starts a nested ctest -j 4 --timeout 600 outside thermal-run. tools/ci/ctest_skips.txt:20 already names fork_ctest_known_fail, so the row's 77 is baselined and the skip is legible rather than silently green.
  • The no-git ROOT now skips with its own reason instead of asking the reader to reconfigure a build tree for a WANT that was empty. The two real cannot tell cases still refuse with 2 and name both shas.

One correction to the body, in the safe direction: it says "eight of the nine fail"; the file at this head has 11 arms and 10 of them fail against main. The ok block in the body lists nine lines. Since the point of this PR is that a count in a body can be wrong about the thing it describes, the count in this body should be regenerated from the final file — 11 arms, 10 failing on main, the passing one being the "does not advise" arm.

Nothing else from me. The follow-up this leaves open, worth saying out loud so it is not mistaken for done: with the row now opt-in, nothing runs the fork's 112 tests in any job — which is what engine#2836 is about from the other end. The opt-in is the right shape for a lane box; wiring the job that sets ONEBIT_FORK_CTEST=1 (and runs under thermal-run) is the part that turns this from "not harmful" into "actually run".

…ow-shebang-optin

# Conflicts:
#	CMakeLists.txt
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

e4152555 — merged main in (no force-push), so the CONFLICTING state is gone.

The conflict was exactly one hunk: CMakeLists.txt next to the census_alert_job anchor, where #2887/#2888 landed warmup_route_check and its neighbours. Both sides kept — fork_ctest_row first, then the warm-up rows — and I re-ran everything after the merge rather than trusting the resolution:

ok   opt-in + matching submodule + a known failure exits 0 (the ratchet answered)
ok   opt-in + matching submodule + a NEW failure exits 1 and names it
fork_ctest_row: ok           # 11 assertions, 8 fixtures
ci_targets_check --self-test: 0 failure(s)
tools/copyright.py --check   # silent

No test-name collision: main's new rows are warmup_route_check / fork_hrx_rows-adjacent, mine is fork_ctest_row, registered once.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at e415255: READY with two small fixes — the opt-in change is right and its test proves it; what it leaves behind is a stale reason in the skip ledger and the same empty-submodule misreport I flagged on #2848.

Ran their row's own tests (tests/fork_ctest_row_test.py, 11 arms, hermetic, ~1 s): fork_ctest_row: ok, 0 failures. Confirmed by hand in a scratch tree with the two ctest_known_fail.* files borrowed from rev-2825:

opt-in unset                                    rc=77  "SKIP -- opt-in: set ONEBIT_FORK_CTEST=1 to run the fork's suite …"
opt-in set, third_party/llama.cpp empty dir      rc=2   "cannot tell: the llama.cpp submodule is at acb1d39…, the tree pins c086759…  reconfigure"

1. The skip ledger's reason is now wrong, and this is the row that made it wrong. tools/ci/ctest_skips.txt:20 still reads "returns 77 until tools/ci/ctest_known_fail.py is on the branch (engine#2825 lands it) and the fork's own build tree exists". After this PR the row returns 77 on every default run of ctest, forever, because of the opt-in — the tool and the build tree are no longer the reason. The baseline is the fleet's ledger of why something is green-without-running, so it should say the new truth:

fork_ctest_known_fail   # opt-in: returns 77 unless ONEBIT_FORK_CTEST=1 (the fork's suite is CPU work that belongs under thermal-run.sh, engine#2848 review)

2. The empty-submodule misreport from #2848 is still there (my .git guard was not taken, which is your call — but the case is unmeasured and it is the one a lane will hit): with third_party/llama.cpp present but not a git repo, git rev-parse HEAD resolves to the engine's own HEAD, so the row says the submodule "is at acb1d39" — this branch's own commit — and advises reconfiguring a build tree. The exit code (2) is right; the diagnosis sends the reader to the wrong repair. Your fixture models "absent" as no directory at all (fixture(..., submodule="absent")), which is the one shape that takes the GOT=none branch, so the arm that would catch this is missing. The fix is the same one line, tested on both submodule forms ($ROOT/third_party/llama.cpp/.git is a file in a submodule/worktree checkout and a directory in a clone):

[ -e "$ROOT/third_party/llama.cpp/.git" ] || { echo "fork_ctest_known_fail: cannot tell: third_party/llama.cpp is not checked out" >&2; exit 2; }

plus a submodule="empty" fixture (mkdir only) asserting rc 2 and "not checked out".

Not asking you to change: the opt-in itself and its reasoning (a nested ctest -j 4 is CPU work inside someone's test run — that is the right call), the single #!/bin/sh shebang, the "no git tree" skip for an exported source tree and its "does not advise reconfiguring" arm, SKIP_RETURN_CODE 77, and the fixture-per-case layout that lets arm 5 and 6 differ only in the submodule. This is the shape I asked for on #2848 and it is better than what I proposed.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at e4152555: READY — the merge of main did not touch this PR's three files, and I re-ran the arms at this head rather than carrying my own verdict across.

Two things worth writing down.

The predecessor verdict was invisible. The comment before this one says VERDICT at c81c9ded4 — a head that stopped being the head when the branch merged main at 06:00:43Z. Nothing was wrong with the review; the gate could not see it. This head has one now.

What the merge changed, so the carry is auditable:

c81c9ded -> e4152555, this PR's files:  tools/ci/fork_ctest_known_fail.sh    unchanged
                                        tests/fork_ctest_row_test.py         unchanged
                                        CMakeLists.txt                       +6 (other lanes' rows: fork_hrx_rows_self, warmup_route_check)

Arms at e4152555 (worktree from the PR ref, python3 tests/fork_ctest_row_test.py): 11 ok — the six fixtures and the five paths that matter, including the two that decide red versus green (opt-in + matching submodule + a NEW failure exits 1), which is the arm a "the ratchet answered" review usually skips.

And the arm that fails without the fix, since a pass alone proves nothing: I put main's script back in place of this one and re-ran the same test file — 10 of 11 fail, starting with a plain ctest skips (77) failing as SyntaxError: invalid syntax at line 38. So the arms are arms.

One scope note, unchanged from the description: ONEBIT_FORK_CTEST=1 still starts a nested ctest -j 4 over the fork's 112 tests outside ~/lb/thermal-run.sh. That is deliberate (the opt-in is for whoever wires the CI job), and nothing in CI sets it — but a lane that sets it on this box is opting into unthrottled CPU, and the skip message is the only thing that says so.

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit e415255

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at e415255: READY

Third re-post — the head has moved three times (900e084 → c81c9de → e415255) and this one is MERGEABLE with the conflict gone. The branch also grew a tool since I last read it, and the tool corrects the issue it serves.

fork_hrx_rows.py corrects engine#2836's own number

The issue says "43 test-hrx-* rows". At the pinned sha that number is wrong, and the tool says so with two independent measurements — "a six-line [script]" and "a structural parse that tracks if() nesting":

38  add_test(NAME test-hrx-…)          the real count
17  carry SKIP_RETURN_CODE 77          skip cleanly, no device
21  do not                             the rows a device-free build would actually execute

That is the number a CI row's message has to carry, and the tool exists so the message cannot drift from the tree: --expect N makes the row fail when the count changes.

Four arms, and two of them are the ones that would be wrong:

only test-hrx rows are counted
a 77 beside the row marks it skippable
a 77 further away does not leak to the next row     <- adjacency without nesting is the bug
an empty file yields no rows, not a claim of zero   <- cannot-tell, not zero

"A 77 further away does not leak to the next row" is the arm that makes the structural parse necessary — a line-based scan cannot tell which SKIP_RETURN_CODE 77 belongs to which add_test, and the difference between 17 and 21 is exactly that. And an empty file yielding "no rows" rather than "zero" is the same refusal as everywhere else in this tree: a count from a file that could not be read is not a count.

add_python_test(fork_hrx_rows_self … --self-test) is at line 709 — the tool is wired, which is the failure I hit on my own #2825 this morning.

What stands

self-test ok, 4 arms, exit 0. The fork_ctest_row test row is at 1478, main still carries #2848's add_test(fork_ctest_known_fail …) at 305–307 intact, and the five wrapper states (no opt-in → 77, tool absent → 77, no build tree → 77, no git in ROOT → 77, submodule absent → 2) are unchanged from the version I verified.

What I did not check, still: app/forward_serve.cpp and tools/ci/serve_routes_check.py arrived in this rebase and are outside the fork-ctest story. They are green and they may well belong — but I read the fork-ctest half, and a verdict that quietly claimed the rest would be the wrong kind of READY.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant