mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
perf: split infra, tooling, and provider test lanes
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
resolveIMessageConfigAllowFrom,
|
||||
resolveIMessageConfigDefaultTo,
|
||||
} from "openclaw/plugin-sdk/channel-config-helpers";
|
||||
import type { ChannelStatusIssue } from "openclaw/plugin-sdk/channel-contract";
|
||||
import { PAIRING_APPROVED_MESSAGE } from "openclaw/plugin-sdk/channel-status";
|
||||
import {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
@@ -11,10 +12,7 @@ import {
|
||||
type OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk/core";
|
||||
import { resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/media-runtime";
|
||||
import {
|
||||
collectStatusIssuesFromLastError,
|
||||
type ChannelStatusIssue,
|
||||
} from "openclaw/plugin-sdk/status-helpers";
|
||||
import { collectStatusIssuesFromLastError } from "openclaw/plugin-sdk/status-helpers";
|
||||
import { looksLikeIMessageTargetId, normalizeIMessageMessagingTarget } from "./normalize.js";
|
||||
|
||||
export {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export { clearAccountEntryFields } from "openclaw/plugin-sdk/core";
|
||||
export type { ChannelPlugin, OpenClawConfig } from "openclaw/plugin-sdk/core";
|
||||
export { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/core";
|
||||
export { clearAccountEntryFields, DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/core";
|
||||
export { buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { channelTestRoots } from "../../vitest.channel-paths.mjs";
|
||||
import { isProviderExtensionRoot } from "../../vitest.extension-provider-paths.mjs";
|
||||
import { BUNDLED_PLUGIN_PATH_PREFIX, BUNDLED_PLUGIN_ROOT_DIR } from "./bundled-plugin-paths.mjs";
|
||||
import { listAvailableExtensionIds } from "./changed-extensions.mjs";
|
||||
|
||||
@@ -89,9 +90,12 @@ export function resolveExtensionTestPlan(params = {}) {
|
||||
}
|
||||
|
||||
const usesChannelConfig = roots.some((root) => channelTestRoots.includes(root));
|
||||
const usesProviderConfig = roots.some((root) => isProviderExtensionRoot(root));
|
||||
const config = usesChannelConfig
|
||||
? "vitest.extension-channels.config.ts"
|
||||
: "vitest.extensions.config.ts";
|
||||
: usesProviderConfig
|
||||
? "vitest.extension-providers.config.ts"
|
||||
: "vitest.extensions.config.ts";
|
||||
const testFileCount = roots.reduce(
|
||||
(sum, root) => sum + countTestFiles(path.join(repoRoot, root)),
|
||||
0,
|
||||
|
||||
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { isChannelSurfaceTestFile } from "../vitest.channel-paths.mjs";
|
||||
import { isProviderExtensionRoot } from "../vitest.extension-provider-paths.mjs";
|
||||
import { isBoundaryTestFile, isBundledPluginDependentUnitTestFile } from "../vitest.unit-paths.mjs";
|
||||
|
||||
const DEFAULT_VITEST_CONFIG = "vitest.unit.config.ts";
|
||||
@@ -15,8 +16,11 @@ const COMMANDS_VITEST_CONFIG = "vitest.commands.config.ts";
|
||||
const CONTRACTS_VITEST_CONFIG = "vitest.contracts.config.ts";
|
||||
const E2E_VITEST_CONFIG = "vitest.e2e.config.ts";
|
||||
const EXTENSION_CHANNELS_VITEST_CONFIG = "vitest.extension-channels.config.ts";
|
||||
const EXTENSION_PROVIDERS_VITEST_CONFIG = "vitest.extension-providers.config.ts";
|
||||
const EXTENSIONS_VITEST_CONFIG = "vitest.extensions.config.ts";
|
||||
const GATEWAY_VITEST_CONFIG = "vitest.gateway.config.ts";
|
||||
const INFRA_VITEST_CONFIG = "vitest.infra.config.ts";
|
||||
const TOOLING_VITEST_CONFIG = "vitest.tooling.config.ts";
|
||||
const UI_VITEST_CONFIG = "vitest.ui.config.ts";
|
||||
const INCLUDE_FILE_ENV_KEY = "OPENCLAW_VITEST_INCLUDE_FILE";
|
||||
|
||||
@@ -77,7 +81,11 @@ function classifyTarget(arg, cwd) {
|
||||
return "e2e";
|
||||
}
|
||||
if (relative.startsWith("extensions/")) {
|
||||
return isChannelSurfaceTestFile(relative) ? "extensionChannel" : "extension";
|
||||
const extensionRoot = relative.split("/").slice(0, 2).join("/");
|
||||
if (isChannelSurfaceTestFile(relative)) {
|
||||
return "extensionChannel";
|
||||
}
|
||||
return isProviderExtensionRoot(extensionRoot) ? "extensionProvider" : "extension";
|
||||
}
|
||||
if (isChannelSurfaceTestFile(relative)) {
|
||||
return "channel";
|
||||
@@ -87,13 +95,17 @@ function classifyTarget(arg, cwd) {
|
||||
}
|
||||
if (
|
||||
relative.startsWith("test/") ||
|
||||
relative.startsWith("src/scripts/") ||
|
||||
relative.startsWith("src/plugins/contracts/") ||
|
||||
relative.startsWith("src/channels/plugins/contracts/") ||
|
||||
relative === "src/config/doc-baseline.integration.test.ts" ||
|
||||
relative === "src/config/schema.base.generated.test.ts" ||
|
||||
relative === "src/config/schema.help.quality.test.ts"
|
||||
) {
|
||||
return "contracts";
|
||||
return relative.startsWith("src/plugins/contracts/") ||
|
||||
relative.startsWith("src/channels/plugins/contracts/")
|
||||
? "contracts"
|
||||
: "tooling";
|
||||
}
|
||||
if (isBundledPluginDependentUnitTestFile(relative)) {
|
||||
return "bundled";
|
||||
@@ -101,6 +113,9 @@ function classifyTarget(arg, cwd) {
|
||||
if (relative.startsWith("src/gateway/")) {
|
||||
return "gateway";
|
||||
}
|
||||
if (relative.startsWith("src/infra/")) {
|
||||
return "infra";
|
||||
}
|
||||
if (relative.startsWith("src/acp/")) {
|
||||
return "acp";
|
||||
}
|
||||
@@ -183,9 +198,11 @@ export function buildVitestRunPlans(args, cwd = process.cwd()) {
|
||||
const orderedKinds = [
|
||||
"default",
|
||||
"boundary",
|
||||
"tooling",
|
||||
"contracts",
|
||||
"bundled",
|
||||
"gateway",
|
||||
"infra",
|
||||
"acp",
|
||||
"command",
|
||||
"autoReply",
|
||||
@@ -193,6 +210,7 @@ export function buildVitestRunPlans(args, cwd = process.cwd()) {
|
||||
"ui",
|
||||
"e2e",
|
||||
"extensionChannel",
|
||||
"extensionProvider",
|
||||
"channel",
|
||||
"extension",
|
||||
];
|
||||
@@ -205,31 +223,37 @@ export function buildVitestRunPlans(args, cwd = process.cwd()) {
|
||||
const config =
|
||||
kind === "boundary"
|
||||
? BOUNDARY_VITEST_CONFIG
|
||||
: kind === "contracts"
|
||||
? CONTRACTS_VITEST_CONFIG
|
||||
: kind === "bundled"
|
||||
? BUNDLED_VITEST_CONFIG
|
||||
: kind === "gateway"
|
||||
? GATEWAY_VITEST_CONFIG
|
||||
: kind === "acp"
|
||||
? ACP_VITEST_CONFIG
|
||||
: kind === "command"
|
||||
? COMMANDS_VITEST_CONFIG
|
||||
: kind === "autoReply"
|
||||
? AUTO_REPLY_VITEST_CONFIG
|
||||
: kind === "agent"
|
||||
? AGENTS_VITEST_CONFIG
|
||||
: kind === "ui"
|
||||
? UI_VITEST_CONFIG
|
||||
: kind === "e2e"
|
||||
? E2E_VITEST_CONFIG
|
||||
: kind === "extensionChannel"
|
||||
? EXTENSION_CHANNELS_VITEST_CONFIG
|
||||
: kind === "channel"
|
||||
? CHANNEL_VITEST_CONFIG
|
||||
: kind === "extension"
|
||||
? EXTENSIONS_VITEST_CONFIG
|
||||
: DEFAULT_VITEST_CONFIG;
|
||||
: kind === "tooling"
|
||||
? TOOLING_VITEST_CONFIG
|
||||
: kind === "contracts"
|
||||
? CONTRACTS_VITEST_CONFIG
|
||||
: kind === "bundled"
|
||||
? BUNDLED_VITEST_CONFIG
|
||||
: kind === "gateway"
|
||||
? GATEWAY_VITEST_CONFIG
|
||||
: kind === "infra"
|
||||
? INFRA_VITEST_CONFIG
|
||||
: kind === "acp"
|
||||
? ACP_VITEST_CONFIG
|
||||
: kind === "command"
|
||||
? COMMANDS_VITEST_CONFIG
|
||||
: kind === "autoReply"
|
||||
? AUTO_REPLY_VITEST_CONFIG
|
||||
: kind === "agent"
|
||||
? AGENTS_VITEST_CONFIG
|
||||
: kind === "ui"
|
||||
? UI_VITEST_CONFIG
|
||||
: kind === "e2e"
|
||||
? E2E_VITEST_CONFIG
|
||||
: kind === "extensionChannel"
|
||||
? EXTENSION_CHANNELS_VITEST_CONFIG
|
||||
: kind === "extensionProvider"
|
||||
? EXTENSION_PROVIDERS_VITEST_CONFIG
|
||||
: kind === "channel"
|
||||
? CHANNEL_VITEST_CONFIG
|
||||
: kind === "extension"
|
||||
? EXTENSIONS_VITEST_CONFIG
|
||||
: DEFAULT_VITEST_CONFIG;
|
||||
const includePatterns =
|
||||
kind === "default" || kind === "e2e"
|
||||
? null
|
||||
|
||||
@@ -67,6 +67,39 @@ describe("config io write", () => {
|
||||
error: () => {},
|
||||
};
|
||||
|
||||
function createBlueBubblesManifestRecord(): PluginManifestRecord {
|
||||
return {
|
||||
id: "bluebubbles",
|
||||
origin: "bundled",
|
||||
channels: ["bluebubbles"],
|
||||
providers: [],
|
||||
cliBackends: [],
|
||||
skills: [],
|
||||
hooks: [],
|
||||
rootDir: "/virtual/plugins/bluebubbles",
|
||||
source: "/virtual/plugins/bluebubbles/openclaw.plugin.json",
|
||||
manifestPath: "/virtual/plugins/bluebubbles/openclaw.plugin.json",
|
||||
channelCatalogMeta: {
|
||||
id: "bluebubbles",
|
||||
label: "BlueBubbles",
|
||||
blurb: "BlueBubbles channel",
|
||||
},
|
||||
channelConfigs: {
|
||||
bluebubbles: {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
enrichGroupParticipantsFromContacts: { type: "boolean", default: true },
|
||||
serverUrl: { type: "string" },
|
||||
},
|
||||
additionalProperties: true,
|
||||
},
|
||||
uiHints: {},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async function withSuiteHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
|
||||
const home = path.join(fixtureRoot, `case-${homeCaseId++}`);
|
||||
await fs.mkdir(home, { recursive: true });
|
||||
@@ -460,6 +493,7 @@ describe("config io write", () => {
|
||||
// write-back leak.
|
||||
mockLoadPluginManifestRegistry.mockReturnValue({
|
||||
diagnostics: [],
|
||||
<<<<<<< HEAD
|
||||
plugins: [
|
||||
createBundledChannelManifestRecord({
|
||||
id: "bluebubbles",
|
||||
@@ -500,6 +534,42 @@ describe("config io write", () => {
|
||||
}),
|
||||
],
|
||||
} satisfies PluginManifestRegistry);
|
||||
||||||| parent of 2d00c45c74 (perf: split infra, tooling, and provider test lanes)
|
||||
plugins: [
|
||||
{
|
||||
id: "bluebubbles",
|
||||
origin: "bundled",
|
||||
channels: ["bluebubbles"],
|
||||
channelCatalogMeta: {
|
||||
id: "bluebubbles",
|
||||
label: "BlueBubbles",
|
||||
blurb: "BlueBubbles channel",
|
||||
},
|
||||
channelConfigs: {
|
||||
bluebubbles: {
|
||||
schema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
enrichGroupParticipantsFromContacts: {
|
||||
type: "boolean",
|
||||
default: true,
|
||||
},
|
||||
serverUrl: {
|
||||
type: "string",
|
||||
},
|
||||
},
|
||||
additionalProperties: true,
|
||||
},
|
||||
uiHints: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
=======
|
||||
plugins: [createBlueBubblesManifestRecord()],
|
||||
});
|
||||
>>>>>>> 2d00c45c74 (perf: split infra, tooling, and provider test lanes)
|
||||
|
||||
await withSuiteHome(async (home) => {
|
||||
const { configPath, io, snapshot } = await writeConfigAndCreateIo({
|
||||
|
||||
@@ -92,7 +92,7 @@ describe("test-projects args", () => {
|
||||
it("routes top-level repo tests to the contracts config", () => {
|
||||
expect(buildVitestRunPlans(["test/appcast.test.ts"])).toEqual([
|
||||
{
|
||||
config: "vitest.contracts.config.ts",
|
||||
config: "vitest.tooling.config.ts",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["test/appcast.test.ts"],
|
||||
watchMode: false,
|
||||
@@ -100,6 +100,17 @@ describe("test-projects args", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("routes script tests to the tooling config", () => {
|
||||
expect(buildVitestRunPlans(["src/scripts/test-projects.test.ts"])).toEqual([
|
||||
{
|
||||
config: "vitest.tooling.config.ts",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["src/scripts/test-projects.test.ts"],
|
||||
watchMode: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("routes contract tests to the contracts config", () => {
|
||||
expect(
|
||||
buildVitestRunPlans(["src/plugins/contracts/memory-embedding-provider.contract.test.ts"]),
|
||||
@@ -116,7 +127,7 @@ describe("test-projects args", () => {
|
||||
it("routes config baseline integration tests to the contracts config", () => {
|
||||
expect(buildVitestRunPlans(["src/config/doc-baseline.integration.test.ts"])).toEqual([
|
||||
{
|
||||
config: "vitest.contracts.config.ts",
|
||||
config: "vitest.tooling.config.ts",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["src/config/doc-baseline.integration.test.ts"],
|
||||
watchMode: false,
|
||||
@@ -168,6 +179,26 @@ describe("test-projects args", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("routes infra targets to the infra config", () => {
|
||||
expect(buildVitestRunPlans(["src/infra/openclaw-root.test.ts"])).toEqual([
|
||||
{
|
||||
config: "vitest.boundary.config.ts",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["src/infra/openclaw-root.test.ts"],
|
||||
watchMode: false,
|
||||
},
|
||||
]);
|
||||
|
||||
expect(buildVitestRunPlans(["src/infra/migrations.test.ts"])).toEqual([
|
||||
{
|
||||
config: "vitest.infra.config.ts",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["src/infra/migrations.test.ts"],
|
||||
watchMode: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("routes acp targets to the acp config", () => {
|
||||
expect(buildVitestRunPlans(["src/acp/control-plane/manager.test.ts"])).toEqual([
|
||||
{
|
||||
@@ -217,7 +248,7 @@ describe("test-projects args", () => {
|
||||
it("widens top-level test helpers to sibling repo tests under contracts", () => {
|
||||
expect(buildVitestRunPlans(["test/helpers/temp-home.ts"])).toEqual([
|
||||
{
|
||||
config: "vitest.contracts.config.ts",
|
||||
config: "vitest.tooling.config.ts",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["test/helpers/**/*.test.ts"],
|
||||
watchMode: false,
|
||||
@@ -271,7 +302,18 @@ describe("test-projects args", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("routes direct provider extension file targets to the extensions config", () => {
|
||||
it("routes direct provider extension file targets to the extension providers config", () => {
|
||||
expect(buildVitestRunPlans(["extensions/openai/openai-codex-provider.test.ts"])).toEqual([
|
||||
{
|
||||
config: "vitest.extension-providers.config.ts",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["extensions/openai/openai-codex-provider.test.ts"],
|
||||
watchMode: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps non-provider extension file targets on the shared extensions config", () => {
|
||||
expect(buildVitestRunPlans(["extensions/firecrawl/index.test.ts"])).toEqual([
|
||||
{
|
||||
config: "vitest.extensions.config.ts",
|
||||
|
||||
@@ -43,7 +43,16 @@ describe("scripts/test-extension.mjs", () => {
|
||||
expect(plan.hasTests).toBe(true);
|
||||
});
|
||||
|
||||
it("resolves provider extensions onto the extensions vitest config", () => {
|
||||
it("resolves provider extensions onto the provider vitest config", () => {
|
||||
const plan = resolveExtensionTestPlan({ targetArg: "openai", cwd: process.cwd() });
|
||||
|
||||
expect(plan.extensionId).toBe("openai");
|
||||
expect(plan.config).toBe("vitest.extension-providers.config.ts");
|
||||
expect(plan.roots).toContain(bundledPluginRoot("openai"));
|
||||
expect(plan.hasTests).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps non-provider extensions on the shared extensions vitest config", () => {
|
||||
const plan = resolveExtensionTestPlan({ targetArg: "firecrawl", cwd: process.cwd() });
|
||||
|
||||
expect(plan.extensionId).toBe("firecrawl");
|
||||
@@ -111,10 +120,10 @@ describe("scripts/test-extension.mjs", () => {
|
||||
it("batches extensions into config-specific vitest invocations", () => {
|
||||
const batch = resolveExtensionBatchPlan({
|
||||
cwd: process.cwd(),
|
||||
extensionIds: ["slack", "firecrawl", "line"],
|
||||
extensionIds: ["slack", "firecrawl", "line", "openai"],
|
||||
});
|
||||
|
||||
expect(batch.extensionIds).toEqual(["firecrawl", "line", "slack"]);
|
||||
expect(batch.extensionIds).toEqual(["firecrawl", "line", "openai", "slack"]);
|
||||
expect(batch.planGroups).toEqual([
|
||||
{
|
||||
config: "vitest.channels.config.ts",
|
||||
@@ -122,6 +131,12 @@ describe("scripts/test-extension.mjs", () => {
|
||||
roots: [bundledPluginRoot("slack"), bundledPluginRoot("line")],
|
||||
testFileCount: expect.any(Number),
|
||||
},
|
||||
{
|
||||
config: "vitest.extension-providers.config.ts",
|
||||
extensionIds: ["openai"],
|
||||
roots: [bundledPluginRoot("openai")],
|
||||
testFileCount: expect.any(Number),
|
||||
},
|
||||
{
|
||||
config: "vitest.extensions.config.ts",
|
||||
extensionIds: ["firecrawl"],
|
||||
|
||||
@@ -8,9 +8,12 @@ import { createAutoReplyVitestConfig } from "../vitest.auto-reply.config.ts";
|
||||
import { createChannelsVitestConfig } from "../vitest.channels.config.ts";
|
||||
import { createCommandsVitestConfig } from "../vitest.commands.config.ts";
|
||||
import { createExtensionChannelsVitestConfig } from "../vitest.extension-channels.config.ts";
|
||||
import { createExtensionProvidersVitestConfig } from "../vitest.extension-providers.config.ts";
|
||||
import { createExtensionsVitestConfig } from "../vitest.extensions.config.ts";
|
||||
import { createGatewayVitestConfig } from "../vitest.gateway.config.ts";
|
||||
import { createInfraVitestConfig } from "../vitest.infra.config.ts";
|
||||
import { createScopedVitestConfig, resolveVitestIsolation } from "../vitest.scoped-config.ts";
|
||||
import { createToolingVitestConfig } from "../vitest.tooling.config.ts";
|
||||
import { createUiVitestConfig } from "../vitest.ui.config.ts";
|
||||
import { BUNDLED_PLUGIN_TEST_GLOB, bundledPluginFile } from "./helpers/bundled-plugin-paths.js";
|
||||
|
||||
@@ -71,10 +74,13 @@ describe("scoped vitest configs", () => {
|
||||
const defaultAcpConfig = createAcpVitestConfig({});
|
||||
const defaultExtensionsConfig = createExtensionsVitestConfig({});
|
||||
const defaultExtensionChannelsConfig = createExtensionChannelsVitestConfig({});
|
||||
const defaultExtensionProvidersConfig = createExtensionProvidersVitestConfig({});
|
||||
const defaultGatewayConfig = createGatewayVitestConfig({});
|
||||
const defaultInfraConfig = createInfraVitestConfig({});
|
||||
const defaultCommandsConfig = createCommandsVitestConfig({});
|
||||
const defaultAutoReplyConfig = createAutoReplyVitestConfig({});
|
||||
const defaultAgentsConfig = createAgentsVitestConfig({});
|
||||
const defaultToolingConfig = createToolingVitestConfig({});
|
||||
const defaultUiConfig = createUiVitestConfig({});
|
||||
|
||||
it("defaults channel tests to non-isolated mode", () => {
|
||||
@@ -138,6 +144,13 @@ describe("scoped vitest configs", () => {
|
||||
expect(defaultExtensionsConfig.test?.include).toEqual(["**/*.test.ts"]);
|
||||
});
|
||||
|
||||
it("normalizes extension provider include patterns relative to the scoped dir", () => {
|
||||
expect(defaultExtensionProvidersConfig.test?.dir).toBe("extensions");
|
||||
expect(defaultExtensionProvidersConfig.test?.include).toEqual(
|
||||
expect.arrayContaining(["openai/**/*.test.ts", "xai/**/*.test.ts", "google/**/*.test.ts"]),
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps telegram plugin tests in extensions while excluding channel-surface plugin roots", () => {
|
||||
const extensionExcludes = defaultExtensionsConfig.test?.exclude ?? [];
|
||||
expect(
|
||||
@@ -155,11 +168,35 @@ describe("scoped vitest configs", () => {
|
||||
expect(defaultExtensionsConfig.test?.setupFiles).toEqual(["test/setup.extensions.ts"]);
|
||||
});
|
||||
|
||||
it("keeps provider plugin tests out of the shared extensions lane", () => {
|
||||
const extensionExcludes = defaultExtensionsConfig.test?.exclude ?? [];
|
||||
expect(
|
||||
extensionExcludes.some((pattern) =>
|
||||
path.matchesGlob("openai/openai-codex-provider.test.ts", pattern),
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("normalizes gateway include patterns relative to the scoped dir", () => {
|
||||
expect(defaultGatewayConfig.test?.dir).toBe("src/gateway");
|
||||
expect(defaultGatewayConfig.test?.include).toEqual(["**/*.test.ts"]);
|
||||
});
|
||||
|
||||
it("normalizes infra include patterns relative to the scoped dir", () => {
|
||||
expect(defaultInfraConfig.test?.dir).toBe("src");
|
||||
expect(defaultInfraConfig.test?.include).toEqual(["infra/**/*.test.ts"]);
|
||||
});
|
||||
|
||||
it("keeps tooling tests in their own lane", () => {
|
||||
expect(defaultToolingConfig.test?.include).toEqual(
|
||||
expect.arrayContaining([
|
||||
"test/**/*.test.ts",
|
||||
"src/scripts/**/*.test.ts",
|
||||
"src/config/doc-baseline.integration.test.ts",
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it("normalizes acp include patterns relative to the scoped dir", () => {
|
||||
expect(defaultAcpConfig.test?.dir).toBe("src/acp");
|
||||
expect(defaultAcpConfig.test?.include).toEqual(["**/*.test.ts"]);
|
||||
|
||||
@@ -9,6 +9,7 @@ export { resolveDefaultVitestPool, resolveLocalVitestMaxWorkers };
|
||||
|
||||
export const rootVitestProjects = [
|
||||
"vitest.unit.config.ts",
|
||||
"vitest.infra.config.ts",
|
||||
"vitest.boundary.config.ts",
|
||||
"vitest.contracts.config.ts",
|
||||
"vitest.bundled.config.ts",
|
||||
@@ -17,9 +18,11 @@ export const rootVitestProjects = [
|
||||
"vitest.commands.config.ts",
|
||||
"vitest.auto-reply.config.ts",
|
||||
"vitest.agents.config.ts",
|
||||
"vitest.tooling.config.ts",
|
||||
"vitest.ui.config.ts",
|
||||
"vitest.channels.config.ts",
|
||||
"vitest.extension-channels.config.ts",
|
||||
"vitest.extension-providers.config.ts",
|
||||
"vitest.extensions.config.ts",
|
||||
] as const;
|
||||
|
||||
|
||||
38
vitest.extension-provider-paths.mjs
Normal file
38
vitest.extension-provider-paths.mjs
Normal file
@@ -0,0 +1,38 @@
|
||||
import { bundledPluginRoot } from "./scripts/lib/bundled-plugin-paths.mjs";
|
||||
|
||||
export const providerExtensionIds = [
|
||||
"amazon-bedrock",
|
||||
"anthropic",
|
||||
"anthropic-vertex",
|
||||
"byteplus",
|
||||
"chutes",
|
||||
"deepseek",
|
||||
"github-copilot",
|
||||
"google",
|
||||
"groq",
|
||||
"huggingface",
|
||||
"kimi-coding",
|
||||
"microsoft",
|
||||
"microsoft-foundry",
|
||||
"minimax",
|
||||
"mistral",
|
||||
"modelstudio",
|
||||
"moonshot",
|
||||
"nvidia",
|
||||
"ollama",
|
||||
"openai",
|
||||
"openrouter",
|
||||
"qianfan",
|
||||
"stepfun",
|
||||
"together",
|
||||
"venice",
|
||||
"volcengine",
|
||||
"xai",
|
||||
"zai",
|
||||
];
|
||||
|
||||
export const providerExtensionTestRoots = providerExtensionIds.map((id) => bundledPluginRoot(id));
|
||||
|
||||
export function isProviderExtensionRoot(root) {
|
||||
return providerExtensionTestRoots.includes(root);
|
||||
}
|
||||
27
vitest.extension-providers.config.ts
Normal file
27
vitest.extension-providers.config.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { providerExtensionTestRoots } from "./vitest.extension-provider-paths.mjs";
|
||||
import { loadPatternListFromEnv } from "./vitest.pattern-file.ts";
|
||||
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
|
||||
|
||||
export function loadIncludePatternsFromEnv(
|
||||
env: Record<string, string | undefined> = process.env,
|
||||
): string[] | null {
|
||||
return loadPatternListFromEnv("OPENCLAW_VITEST_INCLUDE_FILE", env);
|
||||
}
|
||||
|
||||
export function createExtensionProvidersVitestConfig(
|
||||
env: Record<string, string | undefined> = process.env,
|
||||
) {
|
||||
return createScopedVitestConfig(
|
||||
loadIncludePatternsFromEnv(env) ??
|
||||
providerExtensionTestRoots.map((root) => `${root}/**/*.test.ts`),
|
||||
{
|
||||
dir: "extensions",
|
||||
env,
|
||||
name: "extension-providers",
|
||||
passWithNoTests: true,
|
||||
setupFiles: ["test/setup.extensions.ts"],
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export default createExtensionProvidersVitestConfig();
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BUNDLED_PLUGIN_TEST_GLOB } from "./vitest.bundled-plugin-paths.ts";
|
||||
import { extensionExcludedChannelTestGlobs } from "./vitest.channel-paths.mjs";
|
||||
import { providerExtensionTestRoots } from "./vitest.extension-provider-paths.mjs";
|
||||
import { loadPatternListFromEnv } from "./vitest.pattern-file.ts";
|
||||
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
|
||||
|
||||
@@ -20,7 +21,10 @@ export function createExtensionsVitestConfig(
|
||||
setupFiles: ["test/setup.extensions.ts"],
|
||||
// Some bundled plugins still run on the channel surface; keep those roots
|
||||
// out of the shared extensions lane.
|
||||
exclude: extensionExcludedChannelTestGlobs,
|
||||
exclude: [
|
||||
...extensionExcludedChannelTestGlobs,
|
||||
...providerExtensionTestRoots.map((root) => `${root.replace(/^extensions\//u, "")}/**`),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
12
vitest.infra.config.ts
Normal file
12
vitest.infra.config.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
|
||||
|
||||
export function createInfraVitestConfig(env?: Record<string, string | undefined>) {
|
||||
return createScopedVitestConfig(["src/infra/**/*.test.ts"], {
|
||||
dir: "src",
|
||||
env,
|
||||
name: "infra",
|
||||
passWithNoTests: true,
|
||||
});
|
||||
}
|
||||
|
||||
export default createInfraVitestConfig();
|
||||
@@ -129,13 +129,17 @@ export const sharedVitestConfig = {
|
||||
"vitest.extension-channels.config.ts",
|
||||
"vitest.extensions.config.ts",
|
||||
"vitest.gateway.config.ts",
|
||||
"vitest.infra.config.ts",
|
||||
"vitest.live.config.ts",
|
||||
"vitest.performance-config.ts",
|
||||
"vitest.scoped-config.ts",
|
||||
"vitest.shared.config.ts",
|
||||
"vitest.tooling.config.ts",
|
||||
"vitest.ui.config.ts",
|
||||
"vitest.unit.config.ts",
|
||||
"vitest.unit-paths.mjs",
|
||||
"vitest.extension-provider-paths.mjs",
|
||||
"vitest.extension-providers.config.ts",
|
||||
],
|
||||
include: [
|
||||
"src/**/*.test.ts",
|
||||
|
||||
27
vitest.tooling.config.ts
Normal file
27
vitest.tooling.config.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { loadPatternListFromEnv } from "./vitest.pattern-file.ts";
|
||||
import { createScopedVitestConfig } from "./vitest.scoped-config.ts";
|
||||
|
||||
export function loadIncludePatternsFromEnv(
|
||||
env: Record<string, string | undefined> = process.env,
|
||||
): string[] | null {
|
||||
return loadPatternListFromEnv("OPENCLAW_VITEST_INCLUDE_FILE", env);
|
||||
}
|
||||
|
||||
export function createToolingVitestConfig(env?: Record<string, string | undefined>) {
|
||||
return createScopedVitestConfig(
|
||||
loadIncludePatternsFromEnv(env) ?? [
|
||||
"test/**/*.test.ts",
|
||||
"src/scripts/**/*.test.ts",
|
||||
"src/config/doc-baseline.integration.test.ts",
|
||||
"src/config/schema.base.generated.test.ts",
|
||||
"src/config/schema.help.quality.test.ts",
|
||||
],
|
||||
{
|
||||
env,
|
||||
name: "tooling",
|
||||
passWithNoTests: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export default createToolingVitestConfig();
|
||||
@@ -40,6 +40,7 @@ export const bundledPluginDependentUnitTestFiles = [
|
||||
|
||||
export const unitTestAdditionalExcludePatterns = [
|
||||
"src/gateway/**",
|
||||
"src/infra/**",
|
||||
`${BUNDLED_PLUGIN_ROOT_DIR}/**`,
|
||||
"src/browser/**",
|
||||
"src/line/**",
|
||||
@@ -48,6 +49,7 @@ export const unitTestAdditionalExcludePatterns = [
|
||||
"src/commands/**",
|
||||
"src/channels/plugins/contracts/**",
|
||||
"src/plugins/contracts/**",
|
||||
"src/scripts/**",
|
||||
"src/infra/boundary-path.test.ts",
|
||||
"src/infra/git-root.test.ts",
|
||||
"src/infra/home-dir.test.ts",
|
||||
|
||||
Reference in New Issue
Block a user