Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(runner): retain landing assertions and summaries [C7,V4,V10]

Corey Olson98cca4112078
diff --git a/bin/run-tests.js b/bin/run-tests.js
index fac2f1dc..1ba66703 100644
--- a/bin/run-tests.js
+++ b/bin/run-tests.js
@@ -814,6 +814,8 @@ function landingFailureWaived(waivers, file, name) {
/** Run a landing check with execution-ordered failure detection and native runner reporters. */
async function runLandingTests(args, env, concurrency) {
+ const { landingFailureReport } = await import('../src/landing-failure-report.js');
+ const retainedFailure = landingFailureReport();
const waivers = landingWaiverProjection(process.env[LANDING_WAIVERS_ENV]);
const waivedFiles = new Map();
const { run } = await import('node:test');
@@ -1082,6 +1084,7 @@ async function runLandingTests(args, env, concurrency) {
if (waivers.length && details.error?.failureType === 'subtestsFailed' && waivedFiles.get(file) === true) return;
waivedFiles.set(file, false);
firstFailure = { file, name, error: details.error };
+ retainedFailure.remember(data);
// Node emits completion before finalizing its result. Aborting inside that callback
// replaces the real failure with cancellation; let the current publication finish.
queueMicrotask(abortLandingRun);
@@ -1101,6 +1104,7 @@ async function runLandingTests(args, env, concurrency) {
},
});
stream.on('data', event => {
+ event = retainedFailure.event(event);
// Node 22's execution-complete event may describe only the failed file wrapper;
// its ordered failure event retains the actual assertion once reporters drain.
if (event.type === 'test:fail') {
diff --git a/src/gate.js b/src/gate.js
index e293f442..eb02c33a 100644
--- a/src/gate.js
+++ b/src/gate.js
@@ -100,7 +100,7 @@ const FAILURE_RE = /fail|error|expected|received|assert|not ok|✗|×|cannot|und
// A passing test's own lines, whatever its name says: TAP's `ok N` and the `# Subtest:` before it.
const PASSING_RE = /^\s*(ok \d+\b|# Subtest:)/;
// Lines kept under a failure, where test runners say why: the message, expected and actual.
-const CONTEXT_LINES = 10;
+const CONTEXT_LINES = 20;
/** Detect the performance-core budget on Apple Silicon, or the runtime's usable CPU budget elsewhere. */
export function performanceCores() {
@@ -179,6 +179,12 @@ export function digestOf(output) {
const failing = [];
for (let at = 0; at < body.length && failing.length < 40; at += 1) {
if (PASSING_RE.test(body[at]) || !FAILURE_RE.test(body[at])) continue;
+ if (/^\s*not ok \d+/u.test(body[at])) {
+ let end = at + 1;
+ while (end < body.length && !/^\s*(?:# Subtest:|(?:not )?ok \d+|\d+\.\.)/u.test(body[end])) end += 1;
+ // Cancelled siblings are fallout; keep the actual assertion's fields inside the digest cap.
+ if (body.slice(at, end).some(line => /failureType:\s*['"]testAborted['"]/u.test(line))) { at = end - 1; continue; }
+ }
const block = body.slice(at, at + CONTEXT_LINES + 1);
const end = block.findIndex((line, n) => n > 0 && (PASSING_RE.test(line) || /^\s*(not ok \d+|\.\.\.)\s*$|^\s*not ok \d+/.test(line)));
for (const line of end === -1 ? block : block.slice(0, end)) {
diff --git a/src/landing-failure-report.js b/src/landing-failure-report.js
new file mode 100644
index 00000000..0755206c
--- /dev/null
+++ b/src/landing-failure-report.js
@@ -0,0 +1,35 @@
+/** Keep a real completed assertion when cancellation replaces its ordered file result [C7,V4]. */
+
+/** Retain the execution result before abort, without changing native event order or numbering. */
+export function landingFailureReport() {
+ let completed;
+ let replaced = false;
+ let reported = false;
+ return {
+ /** Save the real execution result before abort can replace its ordered file result. */
+ remember(data) { completed = data; },
+ /** Restore only a shadowed failure, leaving authentic reports and their native counts alone. */
+ event(event) {
+ const data = event.data;
+ const error = completed?.details?.error;
+ if (completed && event.type === 'test:fail' && data.file === completed.file && data.name === completed.name
+ && !['testAborted', 'subtestsFailed'].includes(data.details?.error?.failureType)) reported = true;
+ if (!reported && !replaced && completed && event.type === 'test:fail' && data.file === completed.file
+ && data.details?.error?.failureType === 'testAborted' && error
+ && !['testAborted', 'subtestsFailed'].includes(error.failureType)) {
+ replaced = true;
+ return { ...event, data: { ...data, ...completed, nesting: data.nesting, testNumber: data.testNumber } };
+ }
+ if (!replaced) return event;
+ if (event.type === 'test:diagnostic' && data.nesting === 0) {
+ const count = /^(fail|cancelled) (\d+)$/u.exec(data.message);
+ if (count) return { ...event, data: { ...data, message: `${count[1]} ${Number(count[2]) + (count[1] === 'fail' ? 1 : -1)}` } };
+ }
+ if (event.type === 'test:summary' && !data.file && data.counts) {
+ return { ...event, data: { ...data, success: false,
+ counts: { ...data.counts, failed: data.counts.failed + 1, cancelled: data.counts.cancelled - 1 } } };
+ }
+ return event;
+ },
+ };
+}