mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 13:11:40 +00:00
perf: route contract test targets
This commit is contained in:
@@ -11,6 +11,7 @@ const BOUNDARY_VITEST_CONFIG = "vitest.boundary.config.ts";
|
||||
const BUNDLED_VITEST_CONFIG = "vitest.bundled.config.ts";
|
||||
const CHANNEL_VITEST_CONFIG = "vitest.channels.config.ts";
|
||||
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 EXTENSIONS_VITEST_CONFIG = "vitest.extensions.config.ts";
|
||||
const GATEWAY_VITEST_CONFIG = "vitest.gateway.config.ts";
|
||||
@@ -81,6 +82,16 @@ function classifyTarget(arg, cwd) {
|
||||
if (isBoundaryTestFile(relative)) {
|
||||
return "boundary";
|
||||
}
|
||||
if (
|
||||
relative.startsWith("test/") ||
|
||||
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";
|
||||
}
|
||||
if (isBundledPluginDependentUnitTestFile(relative)) {
|
||||
return "bundled";
|
||||
}
|
||||
@@ -163,6 +174,7 @@ export function buildVitestRunPlans(args, cwd = process.cwd()) {
|
||||
const orderedKinds = [
|
||||
"default",
|
||||
"boundary",
|
||||
"contracts",
|
||||
"bundled",
|
||||
"gateway",
|
||||
"command",
|
||||
@@ -181,23 +193,25 @@ export function buildVitestRunPlans(args, cwd = process.cwd()) {
|
||||
const config =
|
||||
kind === "boundary"
|
||||
? BOUNDARY_VITEST_CONFIG
|
||||
: kind === "bundled"
|
||||
? BUNDLED_VITEST_CONFIG
|
||||
: kind === "gateway"
|
||||
? GATEWAY_VITEST_CONFIG
|
||||
: kind === "command"
|
||||
? COMMANDS_VITEST_CONFIG
|
||||
: kind === "autoReply"
|
||||
? AUTO_REPLY_VITEST_CONFIG
|
||||
: kind === "agent"
|
||||
? AGENTS_VITEST_CONFIG
|
||||
: kind === "e2e"
|
||||
? E2E_VITEST_CONFIG
|
||||
: kind === "channel"
|
||||
? CHANNEL_VITEST_CONFIG
|
||||
: kind === "extension"
|
||||
? EXTENSIONS_VITEST_CONFIG
|
||||
: DEFAULT_VITEST_CONFIG;
|
||||
: kind === "contracts"
|
||||
? CONTRACTS_VITEST_CONFIG
|
||||
: kind === "bundled"
|
||||
? BUNDLED_VITEST_CONFIG
|
||||
: kind === "gateway"
|
||||
? GATEWAY_VITEST_CONFIG
|
||||
: kind === "command"
|
||||
? COMMANDS_VITEST_CONFIG
|
||||
: kind === "autoReply"
|
||||
? AUTO_REPLY_VITEST_CONFIG
|
||||
: kind === "agent"
|
||||
? AGENTS_VITEST_CONFIG
|
||||
: kind === "e2e"
|
||||
? E2E_VITEST_CONFIG
|
||||
: kind === "channel"
|
||||
? CHANNEL_VITEST_CONFIG
|
||||
: kind === "extension"
|
||||
? EXTENSIONS_VITEST_CONFIG
|
||||
: DEFAULT_VITEST_CONFIG;
|
||||
const includePatterns =
|
||||
kind === "default" || kind === "e2e"
|
||||
? null
|
||||
|
||||
@@ -89,6 +89,41 @@ 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",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["test/appcast.test.ts"],
|
||||
watchMode: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("routes contract tests to the contracts config", () => {
|
||||
expect(
|
||||
buildVitestRunPlans(["src/plugins/contracts/memory-embedding-provider.contract.test.ts"]),
|
||||
).toEqual([
|
||||
{
|
||||
config: "vitest.contracts.config.ts",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["src/plugins/contracts/memory-embedding-provider.contract.test.ts"],
|
||||
watchMode: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
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",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["src/config/doc-baseline.integration.test.ts"],
|
||||
watchMode: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("routes command targets to the commands config", () => {
|
||||
expect(buildVitestRunPlans(["src/commands/status.summary.test.ts"])).toEqual([
|
||||
{
|
||||
@@ -157,6 +192,17 @@ 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",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["test/helpers/**/*.test.ts"],
|
||||
watchMode: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("routes e2e targets straight to the e2e config", () => {
|
||||
expect(buildVitestRunPlans(["src/commands/models.set.e2e.test.ts"])).toEqual([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user