mirror of
https://github.com/morluto/rea
synced 2026-10-25 22:08:11 -04:00
perf(tests): reuse MCP connections within source matrices
Reuse test-owned stdio MCP connections within two stateless source-analysis matrices while retaining every original CLI/MCP scenario, schema/Evidence checks and test-finished cleanup. Add cross-input identity controls. Validation: 23 focused public-workflow tests and complete check:ci passed; stale-response fault detected. Exact-head hosted CI and available review passed. Pinned workload measurements and their limits are recorded in the PR. Refs #4737.
This commit is contained in:
@@ -3,6 +3,7 @@ import { writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { z } from "zod";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { connectLocalToolsMcp } from "../../fixtures/localToolsMcp.js";
|
||||
import { writeFixtureFiles } from "../../support/javascriptApplicationFixture.js";
|
||||
import { cliTest, type TestCli } from "../../support/cli/cliFixture.js";
|
||||
import { javascriptApplicationAnalysisResultSchema } from "../../../src/domain/javascript/javascriptApplicationAnalysis.js";
|
||||
@@ -265,7 +266,10 @@ cliTest(
|
||||
},
|
||||
] as const;
|
||||
|
||||
for (const surface of ["CLI", "stdio MCP"] as const)
|
||||
for (const surface of ["CLI", "stdio MCP"] as const) {
|
||||
const connection =
|
||||
surface === "stdio MCP" ? await connectLocalToolsMcp() : undefined;
|
||||
const artifacts = new Set<string>();
|
||||
for (const fixture of cases) {
|
||||
const root = await createTestTempDirectory(
|
||||
"rea-electron-early-return-",
|
||||
@@ -277,7 +281,11 @@ cliTest(
|
||||
surface,
|
||||
cli,
|
||||
root,
|
||||
connection?.call,
|
||||
);
|
||||
expect(application.input_path).toBe(root);
|
||||
expect(artifacts.has(application.root_artifact_sha256)).toBe(false);
|
||||
artifacts.add(application.root_artifact_sha256);
|
||||
const observations = application.graph.nodes.flatMap(
|
||||
(node) => node.observations,
|
||||
);
|
||||
@@ -306,6 +314,7 @@ cliTest(
|
||||
);
|
||||
expect(source?.properties.parse_status).toBe(fixture.coverage);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -497,6 +506,8 @@ for (const surface of ["CLI", "stdio MCP"] as const) {
|
||||
cliTest(
|
||||
`retains explicit nested contextBridge members after an unknown spread through ${surface}`,
|
||||
async ({ cli }) => {
|
||||
const connection =
|
||||
surface === "stdio MCP" ? await connectLocalToolsMcp() : undefined;
|
||||
const analyzeBridge = async (api: string) => {
|
||||
const root = await createTestTempDirectory(
|
||||
"rea-electron-spread-bridge-members-",
|
||||
@@ -506,10 +517,20 @@ for (const surface of ["CLI", "stdio MCP"] as const) {
|
||||
const extra = getExtra();
|
||||
contextBridge.exposeInMainWorld("api", ${api});`,
|
||||
});
|
||||
return analyzeJavaScriptDirectory(surface, cli, root);
|
||||
const application = await analyzeJavaScriptDirectory(
|
||||
surface,
|
||||
cli,
|
||||
root,
|
||||
connection?.call,
|
||||
);
|
||||
expect(application.input_path).toBe(root);
|
||||
return application;
|
||||
};
|
||||
const withSpread = await analyzeBridge("{ ...extra, a: { b: 1 }, c: 2 }");
|
||||
const control = await analyzeBridge("{ a: { b: 1 }, c: 2 }");
|
||||
expect(control.root_artifact_sha256).not.toBe(
|
||||
withSpread.root_artifact_sha256,
|
||||
);
|
||||
|
||||
const bridgeObservation = (application: typeof withSpread) =>
|
||||
application.graph.nodes
|
||||
|
||||
@@ -21,11 +21,12 @@ export const runNodeJsonControl = async (
|
||||
return JSON.parse(stdout) as unknown;
|
||||
};
|
||||
|
||||
/** Analyze a directory through a public adapter and validate its result contract. */
|
||||
/** Analyze a directory; a supplied MCP caller reuses its test-owned connection. */
|
||||
export const analyzeJavaScriptDirectory = async (
|
||||
surface: "CLI" | "stdio MCP",
|
||||
cli: TestCli,
|
||||
root: string,
|
||||
mcpCall?: Awaited<ReturnType<typeof connectLocalToolsMcp>>["call"],
|
||||
) => {
|
||||
let document: unknown;
|
||||
if (surface === "CLI") {
|
||||
@@ -36,7 +37,7 @@ export const analyzeJavaScriptDirectory = async (
|
||||
expect(response.exitCode, response.stderr).toBe(0);
|
||||
document = response.json;
|
||||
} else {
|
||||
const { call } = await connectLocalToolsMcp();
|
||||
const call = mcpCall ?? (await connectLocalToolsMcp()).call;
|
||||
const response = await call("analyze_javascript_application", {
|
||||
input_path: root,
|
||||
format: "directory",
|
||||
|
||||
Reference in New Issue
Block a user