scripts(runner): a dirty worktree is refused, and a failing suite is named #2468
No reviewers
Labels
No labels
blocked-on-build
bug
device
device-request
enhancement
from-github
needs-datasheet
needs-info
needs-triage
ready-for-agent
ready-for-human
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!2468
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/runner-honest-failure"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What was wrong
Two halves of one problem:
scripts/run-tests.jslied about failure.test/canonical-urls.test.jseditsREADME.mdand restores it. An interrupted run leftM README.mdbehind, and the run after it reported 6 failures that were that one file -git checkout -- .and the same tree ran 52 passed, 0 failed. Three tool calls went into that, one of them spent believing the wrong suite.stdin is not a ttyand nothing else, so the failure could not be attributed: no suite to re-run, nothing to fix.The guard
git status --porcelainbefore the first suite. Non-empty and no--allow-dirty: print the paths and the two commands that clean them, exit 2 - "I would not start" is not "a suite said so", and reading the second as the first is how the wrong thing gets debugged.--allow-dirtyproceeds with one line, because a worker is sometimes genuinely mid-edit:Nothing ran in the refused case - no banner, no suite line, no summary - so a refusal cannot be read as a green run.
--listskips the guard (a listing runs nothing), and git being unable to answer (tarball install, container without git) means unknown, not dirty: run as before. CI is unaffected: the test job checks out withgit checkout -q -f --detach FETCH_HEADandgit clean -qfdx(ci.yml:847-851), so the tree is clean and the guard costs onegit status.The failure block
Every non-zero suite is named with how it exited and the last 20 lines of its own output, from a real fixture where one suite fails with output and one dies silently:
grep -oE 'test/[A-Za-z0-9._/-]+\.test\.js$'. Moving it into the middle of a sentence would have quietly stopped that working, so the format is asserted against that regex.process.exit(), which drops writes still queued on a pipe - a lost summary reads exactly like a run that named nothing. It setsprocess.exitCodeand lets stdout drain.fs.writeSync, and anexithook says[runner] exited N without printing a summaryif even that was missed. (Windowskillis a TerminateProcess and runs no handler, so the signal path is the Linux one CI takes.)This run left the worktree dirty ... M README.md), so the next run's failure is already explained instead of costing three tool calls.--bailaddsN suite(s) never ran (--bail).;--filter,--verbose,--concurrencyand--listbehave as before.Evidence
test/runner-honest-failure.test.js(37 assertions, 0 failed). There was no existing runner suite -grep -rln run-tests test/returned nothing - so this is a new one, and it tests the runner the only honest way: it builds a real repository in a temp directory (a copy ofscripts/run-tests.js, four suites whose behaviour is known, a committedREADME.md), runs the copy with real child processes, and asserts on what came back. The copy runs against the fixture because the runner derives its root frompath.resolve(__dirname, '..')- no--rootflag, no environment hook to keep in sync.It proves the three things asked for, on behaviour rather than on source:
Refusing to start,test/alpha-pass.test.jsnamed,git checkout -- .printed,--allow-dirtyadvertised, and no banner/summary in the output, which is what proves no suite ran;--allow-dirtyproceeds - exit 0, oneWarning:line naming the flag and the path, and the run finishes green;exit 1 - test/bravo-fail.test.jsandexit 3 - test/charlie-silent.test.jsboth present, the fixture's ownBRAVO-SENTINELline present (so the tail was really captured),printed nothing on stdout or stderrfor the silent one, the passing suites not blamed, and the CIgrepshape asserted.Plus: a run that leaves a tracked file modified is named at the end of that run.
Mutation check - the same suite against the pre-change runner from
main:Gates:
node scripts/syntax-check.js(546 files, all OK),node scripts/check-node-surface.js(no API newer than Node 18), andnode scripts/run-tests.js --filter=runner|canonical|ci-disk|docall green (58/58 canonical, 6 doc suites, 135 assertions).Deliberately left out
test/canonical-urls.test.jsis untouched: the guard is the fix for its leftovers, not a rewrite of how it editsREADME.md.CHANGELOG.mdentry and nodocs/edit - both are hot spots for the parallel worktrees this was written beside; say the word and I will add the line.