Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .agents/skills/testing-workflow/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ suites are outside this distribution's verification.
Artifact-dependent tests require a current `pnpm build`. Keep test state and
reports outside the repository, using synthetic data and temporary directories.

The declared Vitest gate runner serializes test files on Windows to limit
filesystem contention while retaining individual test deadlines. Run the owning
gate for platform acceptance; a direct Vitest invocation uses its default worker
count. Full-runtime smoke children have a 30-second Windows startup budget,
matching ACP; lightweight help and validation checks retain 15 seconds.

## Delivery verification

Run `git diff --check` and the relevant individual gates while editing. Review
Expand Down
4 changes: 4 additions & 0 deletions scripts/run-vitest-suite.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const result = spawnSync(
"run",
"--config",
"vitest.oss.config.mjs",
// These suites create many SQLite databases and watched directories. On
// Windows, concurrent files can exhaust the 5s test budget through I/O
// contention. Serialize files without relaxing individual test deadlines.
...(process.platform === "win32" ? ["--maxWorkers", "1"] : []),
...files,
],
{ stdio: "inherit", cwd: repositoryRoot, env: environment },
Expand Down
21 changes: 15 additions & 6 deletions test/smoke.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import Database from "better-sqlite3";

const root = fileURLToPath(new URL("../", import.meta.url));
const cli = path.join(root, "dist/cli.js");
// Full runtime startup can exceed 15s on Windows CI (ACP took 22s).
// Match the ACP startup budget; lightweight help/validation stays at 15s.
const runtimeTimeoutMs = process.platform === "win32" ? 30000 : 15000;
function assertSuccessfulChild(result) {
assert.equal(result.error, undefined,
`CLI spawn failed: ${result.error?.message}; signal=${result.signal}; stderr=${result.stderr}`);
assert.equal(result.status, 0, result.stderr);
}
const version = JSON.parse(
readFileSync(path.join(root, "packages/tui/package.json"), "utf8"),
).version;
Expand Down Expand Up @@ -46,6 +54,7 @@ function fixture(t, environment = process.env) {
MAVIS_DATA_DIR: dataDir,
MCODE_TEST_NETWORK_AUDIT: audit,
MCODE_TEST_MANAGED_OFFLINE: "1",
MCODE_TEST_PROCESS_PROBE: "1",
NODE_OPTIONS: `--import=${new URL("./network-deny.mjs", import.meta.url).href}`,
},
};
Expand All @@ -70,9 +79,9 @@ test("provider configuration loads from an isolated data directory", (t) => {
const result = spawnSync(process.execPath, [cli, "provider", "list"], {
...fixture(t),
encoding: "utf8",
timeout: 15000,
timeout: runtimeTimeoutMs,
});
assert.equal(result.status, 0, result.stderr);
assertSuccessfulChild(result);
assert.match(result.stdout, /minimax/);

assert.doesNotMatch(result.stdout, /custom_provider:/);
Expand All @@ -97,9 +106,9 @@ test("offline smoke children ignore ambient proxy variables", async (t) => {
const result = spawnSync(process.execPath, [cli, "provider", "list"], {
...options,
encoding: "utf8",
timeout: 15000,
timeout: runtimeTimeoutMs,
});
assert.equal(result.status, 0, result.stderr);
assertSuccessfulChild(result);
assert.match(result.stdout, /minimax/);
assert.match(
readFileSync(options.env.MCODE_TEST_NETWORK_AUDIT + ".managed", "utf8"),
Expand Down Expand Up @@ -225,9 +234,9 @@ test("local plugin browsing remains available with managed services offline", (t
const result = spawnSync(process.execPath, [cli, ...args], {
...options,
encoding: "utf8",
timeout: 15000,
timeout: runtimeTimeoutMs,
});
assert.equal(result.status, 0, result.stderr);
assertSuccessfulChild(result);
const output = JSON.parse(result.stdout);
assert.ok(output !== null);
assert.doesNotMatch(result.stdout, /"official"/);
Expand Down
25 changes: 15 additions & 10 deletions test/source-sync.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -404,16 +404,21 @@ test('suite runner preserves gate arguments and canonicalizes Windows temporary
writeFileSync(path.join(root, 'node_modules/vitest/cli.cjs'), 'console.log(JSON.stringify({args:process.argv.slice(2),temp:process.env.TEMP,tmp:process.env.TMP,cwd:process.cwd()})); process.exit(17);');
const alias = path.join(root, 'temporary-alias');
symlinkSync(path.join(root, 'temporary'), alias, process.platform === 'win32' ? 'junction' : 'dir');
const result = spawnSync(process.execPath, [path.join(root, 'scripts/run-vitest-suite.mjs'), 'fixture'], {
encoding: 'utf8', env: { ...process.env, TEMP: alias, TMP: alias },
});
assert.equal(result.status, 17, result.stderr);
const child = JSON.parse(result.stdout);
assert.deepEqual(child.args, ['run', '--config', 'vitest.oss.config.mjs', 'test/example.test.ts']);
assert.equal(realpathSync(child.cwd), realpathSync(root));
const expected = process.platform === 'win32' ? realpathSync.native(alias) : alias;
assert.equal(child.temp, expected);
assert.equal(child.tmp, expected);
for (const platform of ['linux', 'darwin', 'win32']) {
const preload = path.join(root, 'platform.cjs');
writeFileSync(preload, `Object.defineProperty(process, 'platform', { value: ${JSON.stringify(platform)} });`);
const result = spawnSync(process.execPath, ['--require', preload, path.join(root, 'scripts/run-vitest-suite.mjs'), 'fixture'], {
encoding: 'utf8', env: { ...process.env, TEMP: alias, TMP: alias, TMPDIR: alias },
});
assert.equal(result.status, 17, result.stderr);
const child = JSON.parse(result.stdout);
assert.deepEqual(child.args, ['run', '--config', 'vitest.oss.config.mjs',
...(platform === 'win32' ? ['--maxWorkers', '1'] : []), 'test/example.test.ts']);
assert.equal(realpathSync(child.cwd), realpathSync(root));
const expected = platform === 'win32' ? realpathSync.native(alias) : alias;
assert.equal(child.temp, expected);
assert.equal(child.tmp, expected);
}
});

test('public support forms preserve destination URLs and separate Desktop from CLI reports', () => {
Expand Down
Loading