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(gate): the digest keeps why a test failed, not passing names [V10]

Corey Olsonf25ac77ca97b
diff --git a/src/gate.js b/src/gate.js
index 7b2f26a7..9ccfefc1 100644
--- a/src/gate.js
+++ b/src/gate.js
@@ -15,10 +15,15 @@ const DIGEST_CHARS = 3000;
const TAIL_CHARS = 1000;
const LINE_CHARS = 300;
const FAILURE_RE = /fail|error|expected|received|assert|not ok|✗|×|cannot|undefined|exception/i;
+// 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;
/**
- * The lines of a failure worth an agent's attention: those that look like failures, then the end of
- * the output, within one cap, so a refusal or a retry carries the reason and not the whole log. The
+ * The lines of a failure worth an agent's attention: each line that looks like a failure with the
+ * lines under it that say why, then the end of the output, within one cap, so a refusal or a retry
+ * carries the reason and not the whole log. Passing tests are skipped however they are named. The
* end has its own share of the cap and every line is cut short, so no single long line can push the
* summary out.
*
@@ -38,13 +43,18 @@ export function digestOf(output) {
room -= lines[at].length + 1;
}
room = DIGEST_CHARS - (TAIL_CHARS - room);
+ const body = lines.slice(0, lines.length - tail.length);
const failing = [];
- for (const line of lines.slice(0, lines.length - tail.length)) {
- if (failing.length === 25) break;
- if (FAILURE_RE.test(line) && line.length < room) {
+ for (let at = 0; at < body.length && failing.length < 40; at += 1) {
+ if (PASSING_RE.test(body[at]) || !FAILURE_RE.test(body[at])) 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)) {
+ if (line.length >= room) break;
failing.push(line);
room -= line.length + 1;
}
+ at += (end === -1 ? block.length : end) - 1;
}
return [...failing, ...tail].join('\n');
}
diff --git a/test/gate.test.js b/test/gate.test.js
index 2d38c409..d9c640a1 100644
--- a/test/gate.test.js
+++ b/test/gate.test.js
@@ -19,3 +19,33 @@ test('a digest of many failures stays within its cap and still ends with the sum
assert.match(digest, /^not ok 0 - /);
assert.match(digest, /# tests 200\n# fail 200$/);
});
+
+test('a digest keeps the lines that say why a test failed, and skips passing tests however named [V10]', () => {
+ const tap = [
+ '# Subtest: a lane cannot commit outside its folders',
+ 'ok 1 - a lane cannot commit outside its folders',
+ '# Subtest: an error in the store is reported',
+ 'ok 2 - an error in the store is reported',
+ '# Subtest: add returns the new number',
+ 'not ok 3 - add returns the new number',
+ ' ---',
+ " location: '/repo/test/store.test.js:12:1'",
+ " failureType: 'testCodeFailure'",
+ ' error: |-',
+ ' Expected values to be strictly equal:',
+ ' 2 !== 1',
+ ' expected: 1',
+ ' actual: 2',
+ ' ...',
+ ...Array.from({ length: 30 }, (_, n) => `ok ${n + 4} - filler ${n}`),
+ '# tests 33',
+ '# pass 32',
+ '# fail 1',
+ ].join('\n');
+ const digest = digestOf(tap);
+ assert.doesNotMatch(digest, /cannot commit|error in the store/, 'passing tests are not failures');
+ assert.match(digest, /^not ok 3 - add returns the new number\n/);
+ assert.match(digest, /store\.test\.js:12:1/);
+ assert.match(digest, / {4}2 !== 1\n {2}expected: 1\n {2}actual: 2/);
+ assert.match(digest, /# fail 1$/);
+});