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(core): select tests that launch the cli [C7]

Corey Olsoncfd05797dc08
diff --git a/src/affected-tests.js b/src/affected-tests.js
index 159ec2b1..b8cf8d89 100644
--- a/src/affected-tests.js
+++ b/src/affected-tests.js
@@ -137,7 +137,7 @@ function documentationInputs(path, source, imports, changedDocs = []) {
return inputs;
}
-/** Compile import edges for one tree; computed imports stay attached to their importing file. */
+/** Compile this tree's import edges, plus the literal child-CLI dependency used by fixture modules. */
function graphAt(root, commit, changedDocs = []) {
const modules = modulesAt(root, commit);
const paths = [...modules.keys()];
@@ -171,6 +171,12 @@ function graphAt(root, commit, changedDocs = []) {
if (!reverse.has(dependency)) reverse.set(dependency, new Set());
reverse.get(dependency).add(path);
}
+ // A child process is not an import edge, but tests and helpers that name the CLI entry depend on
+ // every module it imports. Keep this literal path edge narrow and build it for each committed tree.
+ if (modules.get(path).includes('bin/pullboard.js')) {
+ if (!reverse.has('bin/pullboard.js')) reverse.set('bin/pullboard.js', new Set());
+ reverse.get('bin/pullboard.js').add(path);
+ }
});
return { paths, reverse, unknown, always, testTreeReaders, sourceTreeReaders, docInputs };
}
@@ -178,7 +184,8 @@ function graphAt(root, commit, changedDocs = []) {
/**
* Select changed tests and every transitive importer in the old and new trees. Old edges cover
* deletions and renames; declared tree readers also cover changed test or source inputs. Other filesystem
- * reads and process launches are deliberately not import edges, except literal documentation inputs.
+ * reads and process launches are not import edges, except literal documentation inputs and modules that
+ * mention the Pullboard CLI entry (`bin/pullboard.js`), whose imported modules they exercise as subprocesses.
*
* @param {string} root
* @param {{base:string|null, trunk?:string, commit?:string, changed?:string[]}} options
diff --git a/test/affected-tests.test.js b/test/affected-tests.test.js
index 408ea804..0cba82cc 100644
--- a/test/affected-tests.test.js
+++ b/test/affected-tests.test.js
@@ -145,3 +145,34 @@ test('a docs path built inline still selects its reader [V4,C7]', (t) => {
assert.ok(!selected.includes('test/unicode-mark-prefix.test.js'), 'a combining mark before the basename prevents a whole-word match');
assert.ok(!selected.includes('test/unicode-mark-suffix.test.js'), 'a combining mark after the basename prevents a whole-word match');
});
+
+test('a test that spawns the CLI is selected by what the CLI imports [C7]', (t) => {
+ const box = graph(t);
+ box.put('bin/pullboard.js', "import '../src/cli.js';\n");
+ box.put('src/cli.js', "import './serve.js';\n");
+ box.put('src/serve.js', "import './cockpit.js';\n");
+ box.put('src/cockpit.js', 'export const version = 1;\n');
+ box.put('src/unrelated.js', 'export const value = 1;\n');
+ box.put('test/cockpit/fixture.js', "const BIN = '../../bin/pullboard.js';\n");
+ box.put('test/cockpit/items.test.js', "import './fixture.js';\n");
+ box.put('test/direct-cli.test.js', "const BIN = '../bin/pullboard.js';\n");
+ const base = box.commit();
+
+ box.put('src/cockpit.js', 'export const version = 2;\n');
+ const commit = box.commit();
+ const changedCockpit = selectAffectedTests(box.root, { base, commit });
+ assert.equal(changedCockpit.full, false, 'the imported CLI dependency keeps focused selection');
+ assert.ok(changedCockpit.files.includes('test/direct-cli.test.js'), 'a test naming the direct CLI child is selected');
+ assert.ok(changedCockpit.files.includes('test/cockpit/items.test.js'), 'a test importing the CLI-launching fixture is selected transitively');
+
+ box.put('src/unrelated.js', 'export const value = 2;\n');
+ const unrelatedCommit = box.commit();
+ const unrelated = selectAffectedTests(box.root, { base: commit, commit: unrelatedCommit });
+ assert.equal(unrelated.full, false);
+ assert.ok(!unrelated.files.includes('test/direct-cli.test.js'), 'an unrelated source change does not select a direct CLI test');
+ assert.ok(!unrelated.files.includes('test/cockpit/items.test.js'), 'an unrelated source change does not select a fixture caller');
+
+ box.put('src/cli.js', 'export const uncommitted = true;\n');
+ const committedGraph = selectAffectedTests(box.root, { base, commit });
+ assert.deepEqual(committedGraph.files, changedCockpit.files, 'selection ignores uncommitted source bytes');
+});