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(test): pullboard test says why it ran here, and hooks name it [C7]

Corey Olson2e99b3982ffc
diff --git a/src/commands/test.js b/src/commands/test.js
index 657e566e..0e968ca5 100644
--- a/src/commands/test.js
+++ b/src/commands/test.js
@@ -13,7 +13,7 @@ export async function run(io, { first, second, rest, values }) {
const result = await runTestFiles(ctx.info.root, ctx.config, files, { agent: resourceAgent(ctx) ?? `pid-${process.pid}`, onWait: gateWaitReporter(io) });
io.result?.(result);
if (!values.json && result.output) io.say(result.output.trimEnd());
- io.err(`pullboard test: ${result.green ? 'green' : 'red'} on ${result.runner} in ${result.seconds}s`);
+ io.err(`pullboard test: ${result.green ? 'green' : 'red'} on ${result.runner} in ${result.seconds}s${result.local ? `: ${result.local}` : ''}`);
for (const entry of result.known) {
io.err(entry.result === 'red'
? `known main failure: ${entry.file} fails on main ${String(result.main).slice(0, 12)} too`
diff --git a/src/hooks.js b/src/hooks.js
index 91ba3be8..610e2de5 100644
--- a/src/hooks.js
+++ b/src/hooks.js
@@ -793,6 +793,7 @@ export function hookScript(hook, version = installerVersion()) {
return [
'#!/bin/sh',
`# ${HOOK_MARK}: runs the pullboard ${hook} checks. Edit pullboard.json, not this file.`,
+ '# Run tests with pullboard test <test files>: the runner pool first, the per-file timeout, and known main failures named.',
`want='${version}'`,
...(hook === 'commit-msg' ? ['message="$1"'] : []),
'root=$(git rev-parse --show-toplevel)',
diff --git a/src/test-run.js b/src/test-run.js
index 17d8db34..a75ba288 100644
--- a/src/test-run.js
+++ b/src/test-run.js
@@ -29,7 +29,11 @@ import {
} from './main-red.js';
import { Refused } from './refused.js';
import { runnerSource } from './runners.js';
-import { browserFreeChecksEnabled } from './settings.js';
+import {
+ browserFreeChecksEnabled,
+ gateRunnersFirstEnabled,
+ loadMachineSettings,
+} from './settings.js';
/** Quote one argument for the configured focused test command. */
function shellWord(value) {
@@ -82,6 +86,13 @@ async function inCleanCheckout(root, work) {
return result;
}
+/** Why a run stayed on this machine, so the person sees which setting would send it to the runner pool. */
+function localReason() {
+ if (!(loadMachineSettings().runners ?? []).length) return 'no runners are registered on this machine; add one with pullboard runner add <ssh-host> --slots <n> --browser <n>';
+ if (!gateRunnersFirstEnabled()) return 'gate.runnersFirst is off, so a free local slot came first; turn it on with pullboard settings gate.runnersFirst on';
+ return 'no registered runner had a free slot it could use; pullboard resources shows each runner';
+}
+
/**
* Run named test files through a gate slot, which deals them to the registered runners first (#1054); the focused
* runner (pullboard.json affectedTests) gives each file its timeout. A red file is compared with main's recorded
@@ -101,7 +112,8 @@ export async function runTestFiles(root, config, files, { agent, onWait } = {})
return withGateSlot(checkout, (lease) => runProfiledShellAsync(checkout, command, { gateLease: lease, waitMs: lease.waitMs }),
{ browser, gui: testsNeedGui(checkout, paths), shortEligible: true, agent, kind: 'test', onWait });
});
- const result = { green: run.isGreen, output: run.output, runner: run.executionRunner || 'this machine', seconds: Math.round((Date.now() - started) / 1000), files: paths, known: [], main: null };
+ const result = { green: run.isGreen, output: run.output, runner: run.executionRunner || 'this machine', seconds: Math.round((Date.now() - started) / 1000), files: paths, known: [], main: null,
+ ...(run.executionRunner ? {} : { local: localReason() }) };
if (!run.isGreen) {
const compared = await compareMainFailures(root, run.profile, onWait, run.output);
result.main = compared.main;
diff --git a/test/test-command.test.js b/test/test-command.test.js
index 61482d8f..57a361f0 100644
--- a/test/test-command.test.js
+++ b/test/test-command.test.js
@@ -71,3 +71,24 @@ test('pullboard test runs files on the runner pool with a per-file timeout [C7]'
assert.match(text.err, new RegExp(`red on ${HOST}`, 'u'), 'the text form names where it ran');
assert.match(text.err, /known main failure: test\/hang\.test\.js fails on main/u, 'and names the failure main already has');
});
+
+test('pullboard test names why it ran on this machine, and every installed hook points at it [C7]', { timeout: 120_000 }, () => { // budget: hang ceiling for real init, join and one local run; not a speed target.
+ const box = e2e.project('true');
+ const config = JSON.parse(readFileSync(join(box.repo, 'pullboard.json'), 'utf8'));
+ writeFileSync(join(box.repo, 'pullboard.json'), JSON.stringify({ ...config, affectedTests: 'env -u NODE_TEST_CONTEXT node --test' }, null, 2));
+ mkdirSync(join(box.repo, 'test'));
+ writeFileSync(join(box.repo, 'test', 'ok.test.js'), PASSES);
+ box.git(box.repo, 'add', '-A');
+ box.git(box.repo, 'commit', '-q', '-m', 'test: focused runner and one test file');
+ const ran = box.run(box.repo, 'test', 'test/ok.test.js', '--json');
+ assert.equal(ran.code, 0, ran.err);
+ const result = JSON.parse(ran.out);
+ assert.equal(result.runner, 'this machine');
+ assert.match(result.local, /no runners are registered/u, 'the result says why the run stayed here');
+ assert.ok(result.diagnostics.some((line) => /green on this machine in \d+s: no runners are registered.*pullboard runner add/u.test(line)),
+ `the diagnostic names the reason and the command that adds a runner: ${result.diagnostics}`);
+ for (const hook of ['commit-msg', 'pre-commit', 'pre-merge-commit', 'pre-push']) {
+ assert.match(readFileSync(join(box.repo, '.githooks', hook), 'utf8'), /pullboard test <test files>/u, `${hook} names pullboard test`);
+ }
+ assert.match(readFileSync(join(box.repo, 'AGENTS.md'), 'utf8'), /pullboard test <test files>/u, 'the agent guidance names it too');
+});