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.

test(core): cover opaque options through test import bindings [C7]

Corey Olson1f60faa24fc8
diff --git a/test/cpu-load-test-fixture.js b/test/cpu-load-test-fixture.js
index b01606ba..fd8f1da1 100644
--- a/test/cpu-load-test-fixture.js
+++ b/test/cpu-load-test-fixture.js
@@ -9,7 +9,7 @@ import { HOST, installSshStandIn } from './runner-ssh-fixture.js';
const SOURCE = resolve(import.meta.dirname, '..');
/** Build an ordinary CLI fixture whose declared test reports its actual checkout and live holder. */
-export function cpuLoadFixture(e2e, { declaration = '{ cpuLoad: true }', binding = 'test', subtest = null, commonjs = false, dynamicImport = false } = {}) {
+export function cpuLoadFixture(e2e, { declaration = '{ cpuLoad: true }', binding = 'test', subtest = null, commonjs = false, dynamicImport = false, importBinding = null, moduleSpecifier = 'node:test', importedOptions = false } = {}) {
const probeFile = `cpu-probe.test.${commonjs ? 'cjs' : 'js'}`;
const box = e2e.project(`node bin/run-tests.js test/${probeFile}`);
const bin = join(box.dir, 'ssh-bin');
@@ -20,11 +20,13 @@ export function cpuLoadFixture(e2e, { declaration = '{ cpuLoad: true }', binding
cpSync(join(SOURCE, 'src'), join(box.repo, 'src'), { recursive: true });
cpSync(join(SOURCE, 'bin'), join(box.repo, 'bin'), { recursive: true });
writeFileSync(join(box.repo, 'package.json'), JSON.stringify({ name: 'pullboard', version: '1.0.0', type: 'module' }) + '\n');
+ if (importedOptions) writeFileSync(join(box.repo, 'test', 'options.js'), 'export const options = { cpuLoad: true };\n');
writeFileSync(join(box.repo, 'test', probeFile), `${commonjs
? `const { test: ${binding}, after: finish } = require('node:test');\nconst { DatabaseSync } = require('node:sqlite');`
: dynamicImport
? `const { default: ${binding}, after: finish } = await import('node:test');\nimport { DatabaseSync } from 'node:sqlite';`
- : `import { test${binding === 'test' ? '' : ` as ${binding}`}, after as finish } from 'node:test';\nimport { DatabaseSync } from 'node:sqlite';`}
+ : `import { ${importBinding ?? `test${binding === 'test' ? '' : ` as ${binding}`}`}, after as finish } from '${moduleSpecifier}';\nimport { DatabaseSync } from 'node:sqlite';`}
+${importedOptions ? "import { options } from './options.js';" : ''}
// Example text is not a declaration: { cpuLoad: true }
const example = '{ cpuLoad: true }';
finish(() => {});
diff --git a/test/cpu-load-tests.test.js b/test/cpu-load-tests.test.js
index 1b0ba9ce..b7468880 100644
--- a/test/cpu-load-tests.test.js
+++ b/test/cpu-load-tests.test.js
@@ -187,3 +187,19 @@ test('dynamic node:test registration with opaque options uses its runner [C7]',
assert.equal(remote.executor?.runnerExecution, true);
assert.notEqual(remote.executor?.cwd, box.repo);
});
+
+
+// Test-first binding controls: imported opaque options must not evade registration discovery.
+for (const [kind, importBinding, moduleSpecifier] of [
+ ['commented', 'test /* registration */ as check', 'node:test'],
+ ['quoted', "'test' as check", 'node:test'],
+ ['escaped module', 'test as check', String.raw`node:t\u0065st`],
+]) test(`a ${kind} test import with opaque imported options uses its runner [C7]`, async () => {
+ const box = cpuLoadFixture(e2e, { binding: 'check', importBinding, moduleSpecifier,
+ importedOptions: true, declaration: 'options' });
+ const remote = await box.runGate();
+ assert.equal(remote.result.status, 0, remote.result.context);
+ assert.equal(box.requestsMade().length, 1, 'valid import binding syntax cannot hide unreadable test options');
+ assert.equal(remote.executor?.runnerExecution, true);
+ assert.notEqual(remote.executor?.cwd, box.repo);
+});