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): a name pattern after the file selects its case [C7]

Corey Olsonb77ecaeb34a1
diff --git a/bin/run-tests.js b/bin/run-tests.js
index 347c084f..554ad61e 100644
--- a/bin/run-tests.js
+++ b/bin/run-tests.js
@@ -259,10 +259,16 @@ function testEnvironment(sandbox, gateMarkers = {}) {
function runTests(args, env, concurrency) {
let files = concurrency.files;
const forwarded = [];
+ const namePatterns = [];
for (let at = 0; at < args.length; at += 1) {
const argument = args[at];
if (argument === '--') { forwarded.push(...args.slice(at)); break; }
- if (/^--test[-_]concurrency(?:=|$)/u.test(argument)) {
+ if (/^--test[-_]name[-_]pattern(?:=|$)/u.test(argument)) {
+ // Node reads a name pattern only before the files, so a pattern written after them moves ahead [C7].
+ const value = argument.includes('=') ? argument.slice(argument.indexOf('=') + 1) : args[++at];
+ if (value === undefined) throw new Error('--test-name-pattern requires a value');
+ namePatterns.push(`--test-name-pattern=${value}`);
+ } else if (/^--test[-_]concurrency(?:=|$)/u.test(argument)) {
const value = argument.includes('=') ? argument.slice(argument.indexOf('=') + 1) : args[++at];
if (!/^[1-9][0-9]*$/u.test(value ?? '') || !Number.isSafeInteger(Number(value))) {
throw new Error('--test-concurrency must be a positive integer');
@@ -281,6 +287,7 @@ function runTests(args, env, concurrency) {
...(!reporter ? ['--test-reporter=tap'] : []),
'--import',
runner,
+ ...namePatterns,
...forwarded,
];
return spawnSync(process.execPath, nodeArgs, { env, stdio: 'inherit' });
diff --git a/test/run-tests.test.js b/test/run-tests.test.js
index 05f086a3..efabffe9 100644
--- a/test/run-tests.test.js
+++ b/test/run-tests.test.js
@@ -1689,3 +1689,12 @@ test('a focused test run holds a gate slot [C7]', async (t) => {
if (testFailure) throw testFailure;
if (cleanupFailure) throw cleanupFailure;
});
+
+test('a test name pattern after the file selects only its case [C7]', () => {
+ const root = mkdtempSync(join(tmpdir(), 'pullboard-pattern-after-')); try {
+ writeFileSync(join(root, 'pattern.test.mjs'), "import { test } from 'node:test';\ntest('alpha case runs', () => {});\ntest('beta case runs', () => {});\n");
+ for (const args of [['pattern.test.mjs', '--test-name-pattern', 'alpha'], ['pattern.test.mjs', '--test-name-pattern=alpha']]) {
+ const result = runFixtureChild(process.execPath, [runner, ...args], { cwd: root, encoding: 'utf8' }); assert.equal(result.status, 0, result.context);
+ assert.match(result.stdout, /ok [0-9]+ - alpha case runs[\s\S]*# tests 1\b/u, `${args.join(' ')} selects one case`); assert.doesNotMatch(result.stdout, /beta case runs/u, `${args.join(' ')} ran the unselected case`); }
+ } finally { rmSync(root, { recursive: true, force: true }); }
+});