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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(runner): refuse name patterns that select no native cases [C7]
Corey Olson5ec4313754fb
diff --git a/bin/run-tests.js b/bin/run-tests.jsindex f17bbf94..565f190a 100644--- a/bin/run-tests.js+++ b/bin/run-tests.js@@ -16,6 +16,10 @@ import { after, afterEach, beforeEach } from 'node:test';import { Worker } from 'node:worker_threads';import { randomUUID } from 'node:crypto';import { channel } from 'node:diagnostics_channel';+import {+ selectedTestResult,+ testSelectionPatterns,+} from '../src/test-selection.js';import { AGENT_SHELL_MARKERS, SSH_SHELL_MARKERS } from '../src/person.js';import { isLandingWorkerIdentityTimeout, landingWorkerIdentityQuery, parseLandingWorkerIdentity } from '../src/landing-worker-identity.js';import { foreignNodeOptions, isolateTestMachine } from '../src/test-isolation.js';@@ -303,6 +307,15 @@ function runTests(args, env, concurrency) {} else selectors.push(argument);}const reporter = args.some((argument) => argument === '--test-reporter' || argument.startsWith('--test-reporter='));+ const selectionReporter = [];+ if (env.PULLBOARD_TEST_SELECTION) {+ const reporters = placed.filter(argument => /^--test-reporter(?:=|$)/u.test(argument)).length;+ const destinations = placed.filter(argument => /^--test-reporter-destination(?:=|$)/u.test(argument)).length;+ if (destinations && destinations !== reporters) throw new Error('each --test-reporter requires a matching --test-reporter-destination');+ if (reporter && !destinations) for (let index = 0; index < reporters; index++) selectionReporter.push('--test-reporter-destination=stdout');+ if (!reporter && !env.PULLBOARD_TEST_ACTIONS) selectionReporter.push('--test-reporter-destination=stdout');+ selectionReporter.push(`--test-reporter=${fileURLToPath(new URL('../src/test-selection.js', import.meta.url))}`, `--test-reporter-destination=${devNull}`);+ }const nodeArgs = ['--disable-warning=ExperimentalWarning','--test',@@ -311,6 +324,7 @@ function runTests(args, env, concurrency) {'--import',runner,...placed,+ ...selectionReporter,...selectors,];return spawnSync(process.execPath, nodeArgs, { env, stdio: 'inherit' });@@ -894,6 +908,7 @@ async function runLandingTests(args, env, concurrency) {delete options.selectedFiles;const reporterEntries = options.reporters;if (process.env.PULLBOARD_TEST_ACTIONS) reporterEntries.push({ reporter: fileURLToPath(new URL('../src/test-action-reporter.js', import.meta.url)), destination: devNull });+ if (testEnv.PULLBOARD_TEST_SELECTION) reporterEntries.push({ reporter: fileURLToPath(new URL('../src/test-selection.js', import.meta.url)), destination: devNull });delete options.reporters;const loadedReporters = [];for (const entry of reporterEntries) {@@ -1384,6 +1399,9 @@ function shardArguments(args) {/** Run tests in the disposable environment, preserving a marker only when a parent holds the slot. */async function executeTests(args, sandbox, gateMarkers, fullSuite, concurrency) {const env = testEnvironment(sandbox, gateMarkers);+ const patterns = testSelectionPatterns(args);+ if (patterns.length) env.PULLBOARD_TEST_SELECTION = join(sandbox, 'selected-tests.json');+ else delete env.PULLBOARD_TEST_SELECTION;// This is an inner file limit; the real machine gate/browser lease remains unchanged.env.PULLBOARD_TEST_BROWSER_RESOURCE = 'test-browser-files:' + randomUUID();env.PULLBOARD_TEST_BROWSER_CAPACITY = String(concurrency.browser);@@ -1415,7 +1433,7 @@ async function executeTests(args, sandbox, gateMarkers, fullSuite, concurrency)? await runLandingTests(selectedArgs, env, concurrency): runTests(selectedArgs, env, concurrency);if (result.error) throw result.error;- return result;+ return selectedTestResult(result, env.PULLBOARD_TEST_SELECTION, patterns, explicitTestFiles(selectedArgs));}/**diff --git a/src/test-selection.js b/src/test-selection.jsnew file mode 100644index 00000000..c9f0c35f--- /dev/null+++ b/src/test-selection.js@@ -0,0 +1,39 @@+/** Count selected native cases independently of the caller's public reporter [C7,S13]. */+import {+ readFileSync,+ writeFileSync,+} from 'node:fs';++/** Read the same name-pattern spellings the ordinary runner accepts. */+export function testSelectionPatterns(args) {+ const patterns = [];+ for (let index = 0; index < args.length && args[index] !== '--'; index++) {+ if (!/^--test[-_]name[-_]pattern(?:=|$)/u.test(args[index])) continue;+ const value = args[index].includes('=') ? args[index].slice(args[index].indexOf('=') + 1) : args[++index];+ if (value !== undefined) patterns.push(value);+ }+ return patterns;+}++/** A successful Node process cannot turn missing native selection evidence into a green check. */+export function selectedTestResult(result, record, patterns, files) {+ if (result.status !== 0 || !patterns.length) return result;+ let cases = 0;+ try { cases = JSON.parse(readFileSync(record, 'utf8')).cases; }+ catch { /* A missing or malformed internal reporter result fails closed. */ }+ if (Number.isSafeInteger(cases) && cases > 0) return result;+ process.stderr.write(`run-tests: NO_TESTS_MATCHED: patterns ${JSON.stringify(patterns)} selected no proven test case in ${JSON.stringify(files)}\n`);+ return { ...result, status: 1 };+}++/** Only child-file summaries contain native case counts; the parent aggregate includes file wrappers. */+export default async function* recordSelectedTests(events) {+ let cases = 0;+ for await (const event of events) {+ if (event.type !== 'test:summary' || !event.data.file) continue;+ const count = event.data.counts?.tests;+ if (!Number.isSafeInteger(count) || count < 0 || !Number.isSafeInteger(cases + count)) throw new Error('native selected-test counts are unavailable');+ cases += count;+ }+ writeFileSync(process.env.PULLBOARD_TEST_SELECTION, JSON.stringify({ cases }), { mode: 0o600 });+}diff --git a/test/test-runner.test.js b/test/test-runner.test.jsindex 8359c74f..241cbe9b 100644--- a/test/test-runner.test.js+++ b/test/test-runner.test.js@@ -197,3 +197,26 @@ test('a name pattern that matches no test fails with NO_TESTS_MATCHED [C7,S13]',assert.equal(quietMatch.stdout, '', 'observing selection adds no public reporter output');assert.equal(readFileSync(box.marker, 'utf8'), 'xxx');});+++test('a name pattern that matches no test fails with NO_TESTS_MATCHED in a landing [C7,S13]', (t) => {+ const box = discoveryFixture(t);+ const runner = join(box.bin, 'run-tests.js');+ const file = join(box.root, 'test', 'one.test.js');+ const env = { ...process.env, PULLBOARD_LANDING_RUN: '1' };+ delete env.NODE_TEST_CONTEXT;+ /** Exercise the real landing API and its independent reporter on private files. */+ const execute = (...args) => spawnSync(process.execPath, [runner, ...args], { cwd: box.root, env, encoding: 'utf8' });+ const missing = execute('--test-name-pattern=absent landing case 1018', file);+ assert.notEqual(missing.status, 0, `${missing.stdout}${missing.stderr}`);+ assert.match(missing.stderr, /NO_TESTS_MATCHED/u);+ assert.equal(existsSync(box.marker), false);+ const silent = join(box.root, 'silent.mjs');+ const output = join(box.root, 'selected-output.txt');+ writeFileSync(silent, 'export default async function* (events) { for await (const event of events) {} }\n');+ const matched = execute('--test-reporter', silent, '--test-reporter-destination', output,+ '--test-name-pattern', 'one discovered test', file);+ assert.equal(matched.status, 0, `${matched.stdout}${matched.stderr}`);+ assert.equal(readFileSync(output, 'utf8'), '', 'the selected reporter destination stays silent');+ assert.equal(readFileSync(box.marker, 'utf8'), 'x');+});