CI / verify (pull_request) Successful in 1m5s
CI / infrastructure-smoke (pull_request) Successful in 37s
CI / migration-smoke (pull_request) Successful in 1m55s
CI / image-build (pull_request) Successful in 24s
CI / deploy-smoke (same-origin) (pull_request) Successful in 49s
CI / deploy-smoke (split) (pull_request) Successful in 1m31s
Four Core tests prove that importing a module has no side effects. Each one does a cold dynamic import() of a large Core source graph inside its test body: - doctor-import - module-http-import - cli-bootstrap-platform-owner - cli-create-initial-owner (its first test) Vitest transforms and evaluates that graph on demand, so the CPU-bound cost counts against the default 5 s per-test timeout. Ordinary test files import at the top level, outside any test timeout. There is no subprocess, shared resource, or test bug. Measured on six cores: - alone: 0.7–1.2 s; - alongside five other packages' suites, as in a full pnpm verify: 3.0–5.4 s (doctor-import reached 5,400 ms). A shared IMPORT_SAFETY_TEST_TIMEOUT_MS of 30 s (core/tests/support/ import-safety.ts) now applies to exactly these four tests. That is about five times the slowest time measured under load, the same as the repository's integration-test timeout, and still bounded, so an import that genuinely hangs fails. Assertions, coverage, the global Vitest timeout, parallelism, and production code are unchanged; there are no retries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { IMPORT_SAFETY_TEST_TIMEOUT_MS } from "./support/import-safety.js";
|
|
|
|
const discoverModules = vi.fn();
|
|
const discoverModuleSchemas = vi.fn();
|
|
const discoverModuleMigrations = vi.fn();
|
|
const startModuleRuntime = vi.fn();
|
|
const createPostgresMigrationDatabase = vi.fn();
|
|
const planModuleMigrations = vi.fn();
|
|
|
|
vi.mock("../src/modules/index.js", async (importOriginal) => ({
|
|
...(await importOriginal<typeof import("../src/modules/index.js")>()),
|
|
discoverModuleMigrations,
|
|
discoverModules,
|
|
discoverModuleSchemas,
|
|
startModuleRuntime,
|
|
}));
|
|
|
|
vi.mock("../src/migrations/index.js", async (importOriginal) => ({
|
|
...(await importOriginal<typeof import("../src/migrations/index.js")>()),
|
|
createPostgresMigrationDatabase,
|
|
planModuleMigrations,
|
|
}));
|
|
|
|
describe("Doctor import safety", () => {
|
|
it(
|
|
"does not discover, connect, plan, or print when imported",
|
|
async () => {
|
|
const log = vi.spyOn(console, "log").mockImplementation(() => undefined);
|
|
const error = vi.spyOn(console, "error").mockImplementation(() => undefined);
|
|
|
|
await import("../src/diagnostics/index.js");
|
|
await import("../src/cli/doctor.js");
|
|
await import("../src/index.js");
|
|
|
|
expect(discoverModules).not.toHaveBeenCalled();
|
|
expect(discoverModuleSchemas).not.toHaveBeenCalled();
|
|
expect(discoverModuleMigrations).not.toHaveBeenCalled();
|
|
expect(startModuleRuntime).not.toHaveBeenCalled();
|
|
expect(createPostgresMigrationDatabase).not.toHaveBeenCalled();
|
|
expect(planModuleMigrations).not.toHaveBeenCalled();
|
|
expect(log).not.toHaveBeenCalled();
|
|
expect(error).not.toHaveBeenCalled();
|
|
|
|
log.mockRestore();
|
|
error.mockRestore();
|
|
},
|
|
IMPORT_SAFETY_TEST_TIMEOUT_MS,
|
|
);
|
|
});
|