mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:40:44 +00:00
test: speed up unit fast lane
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildVitestCapabilityShimAliasMap,
|
||||
loadBundledCapabilityRuntimeRegistry,
|
||||
} from "./bundled-capability-runtime.js";
|
||||
import { buildVitestCapabilityShimAliasMap } from "./bundled-capability-runtime.js";
|
||||
|
||||
describe("buildVitestCapabilityShimAliasMap", () => {
|
||||
it("keeps scoped and unscoped capability shim aliases aligned", () => {
|
||||
@@ -25,21 +22,3 @@ describe("buildVitestCapabilityShimAliasMap", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("loadBundledCapabilityRuntimeRegistry", () => {
|
||||
it("captures bundled migration providers", () => {
|
||||
const registry = loadBundledCapabilityRuntimeRegistry({
|
||||
pluginIds: ["migrate-hermes"],
|
||||
pluginSdkResolution: "dist",
|
||||
});
|
||||
|
||||
const record = registry.plugins.find((entry) => entry.id === "migrate-hermes");
|
||||
expect(record?.migrationProviderIds).toEqual(["hermes"]);
|
||||
expect(
|
||||
registry.migrationProviders.map((entry) => ({
|
||||
pluginId: entry.pluginId,
|
||||
providerId: entry.provider.id,
|
||||
})),
|
||||
).toEqual([{ pluginId: "migrate-hermes", providerId: "hermes" }]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
collectBroadUnitFastTestCandidates,
|
||||
collectUnitFastTestCandidates,
|
||||
collectUnitFastTestFileAnalysis,
|
||||
forcedUnitFastTestFiles,
|
||||
getUnitFastTestFiles,
|
||||
isUnitFastTestFile,
|
||||
resolveUnitFastTestIncludePattern,
|
||||
@@ -59,6 +60,19 @@ describe("unit-fast vitest lane", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("routes audited stateful-looking tests through the fast lane", () => {
|
||||
const analysis = collectUnitFastTestFileAnalysis();
|
||||
const forcedAnalysis = analysis.filter((entry) => forcedUnitFastTestFiles.includes(entry.file));
|
||||
const unitFastTestFiles = getUnitFastTestFiles();
|
||||
|
||||
expect(forcedAnalysis).toHaveLength(forcedUnitFastTestFiles.length);
|
||||
for (const file of forcedUnitFastTestFiles) {
|
||||
expect(unitFastTestFiles).toContain(file);
|
||||
expect(isUnitFastTestFile(file)).toBe(true);
|
||||
}
|
||||
expect(forcedAnalysis.every((entry) => entry.forced && entry.unitFast)).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps broad audit candidates separate from automatically routed unit-fast tests", () => {
|
||||
const currentCandidates = collectUnitFastTestCandidates();
|
||||
const broadCandidates = collectBroadUnitFastTestCandidates();
|
||||
|
||||
@@ -52,6 +52,15 @@ const unitFastCandidateGlobs = [
|
||||
"src/wizard/**/*.test.ts",
|
||||
"test/**/*.test.ts",
|
||||
];
|
||||
export const forcedUnitFastTestFiles = [
|
||||
"src/crestodian/overview.test.ts",
|
||||
"src/flows/channel-setup.test.ts",
|
||||
"src/memory-host-sdk/host/session-files.test.ts",
|
||||
"src/node-host/invoke-system-run-plan.test.ts",
|
||||
"src/node-host/invoke-system-run.test.ts",
|
||||
"src/pairing/pairing-store.test.ts",
|
||||
];
|
||||
const forcedUnitFastTestFileSet = new Set(forcedUnitFastTestFiles);
|
||||
const unitFastCandidateExactFiles = [...pluginSdkLightTestFiles, ...commandsLightTestFiles];
|
||||
const broadUnitFastCandidateGlobs = [
|
||||
"src/**/*.test.ts",
|
||||
@@ -171,9 +180,9 @@ export function collectUnitFastTestCandidates(cwd = process.cwd()) {
|
||||
matchesAnyGlob(file, unitFastCandidateGlobs) &&
|
||||
!matchesAnyGlob(file, broadUnitFastCandidateSkipGlobs),
|
||||
);
|
||||
return [...new Set([...discovered, ...unitFastCandidateExactFiles])].toSorted((a, b) =>
|
||||
a.localeCompare(b),
|
||||
);
|
||||
return [
|
||||
...new Set([...discovered, ...unitFastCandidateExactFiles, ...forcedUnitFastTestFiles]),
|
||||
].toSorted((a, b) => a.localeCompare(b));
|
||||
}
|
||||
|
||||
export function collectBroadUnitFastTestCandidates(cwd = process.cwd()) {
|
||||
@@ -185,9 +194,9 @@ export function collectBroadUnitFastTestCandidates(cwd = process.cwd()) {
|
||||
matchesAnyGlob(file, broadUnitFastCandidateGlobs) &&
|
||||
!matchesAnyGlob(file, broadUnitFastCandidateSkipGlobs),
|
||||
);
|
||||
return [...new Set([...discovered, ...unitFastCandidateExactFiles])].toSorted((a, b) =>
|
||||
a.localeCompare(b),
|
||||
);
|
||||
return [
|
||||
...new Set([...discovered, ...unitFastCandidateExactFiles, ...forcedUnitFastTestFiles]),
|
||||
].toSorted((a, b) => a.localeCompare(b));
|
||||
}
|
||||
|
||||
export function collectUnitFastTestFileAnalysis(cwd = process.cwd(), options = {}) {
|
||||
@@ -208,9 +217,11 @@ export function collectUnitFastTestFileAnalysis(cwd = process.cwd(), options = {
|
||||
};
|
||||
}
|
||||
const reasons = classifyUnitFastTestFileContent(source);
|
||||
const forced = forcedUnitFastTestFileSet.has(file);
|
||||
return {
|
||||
file,
|
||||
unitFast: reasons.length === 0,
|
||||
unitFast: forced || reasons.length === 0,
|
||||
forced,
|
||||
reasons,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user