From 1a808dd2a239f5259af549de3a40103a03d4c05d Mon Sep 17 00:00:00 2001
From: morluto <76467478+morluto@users.noreply.github.com>
Date: Sat, 24 Oct 2026 06:37:26 +0800
Subject: [PATCH] test(perf): reuse keyed archive CLI and MCP sessions
---
.../keyedArchiveXmlNumbers.test.ts | 23 ++++++++-----------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/tests/acceptance/applications/keyedArchiveXmlNumbers.test.ts b/tests/acceptance/applications/keyedArchiveXmlNumbers.test.ts
index a9dfaf705f..418f86845c 100644
--- a/tests/acceptance/applications/keyedArchiveXmlNumbers.test.ts
+++ b/tests/acceptance/applications/keyedArchiveXmlNumbers.test.ts
@@ -7,9 +7,8 @@ import { expect } from "vitest";
import { keyedArchiveResultSchema } from "../../../src/domain/apple/keyedArchive.js";
import { parseEvidence } from "../../../src/domain/evidence.js";
-import { connectLocalToolsMcp } from "../../fixtures/localToolsMcp.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
-import { cliTest } from "../../support/cli/cliFixture.js";
+import { cliTest, runFileCli } from "../../support/cli/cliFixture.js";
cliTest.for([
{ name: "plain real", element: "1.25", expected: 1.25 },
@@ -73,11 +72,9 @@ cliTest.for([
);
const path = join(root, "archive.plist");
await writeFile(path, bytes);
- const { call } = await connectLocalToolsMcp({
- HOME: root,
- USERPROFILE: root,
- });
- const output = await cli.run({
+ const call = await cli.sharedMcpCall?.();
+ if (call === undefined) throw new Error("Missing file-scoped MCP session");
+ const output = await runFileCli(cli, {
arguments: [
"inspect-keyed-archive",
path,
@@ -89,7 +86,7 @@ cliTest.for([
"1",
"--json",
],
- environment: { HOME: root, USERPROFILE: root, REA_LOG_LEVEL: "silent" },
+ environment: { REA_LOG_LEVEL: "silent" },
});
expect(output.exitCode, output.stderr).toBe(0);
const result = keyedArchiveResultSchema.parse(
@@ -141,10 +138,8 @@ cliTest(
"refuses invalid data without publishing observed bytes through CLI and MCP",
async ({ cli }) => {
const root = await createTestTempDirectory("rea-keyed-data-refusal-");
- const { call } = await connectLocalToolsMcp({
- HOME: root,
- USERPROFILE: root,
- });
+ const call = await cli.sharedMcpCall?.();
+ if (call === undefined) throw new Error("Missing file-scoped MCP session");
for (const [name, element, reason] of [
["non-ascii", "AQ\u0085ID", "non-ascii"],
["markup", "AQID", "markup"],
@@ -160,9 +155,9 @@ cliTest(
}).replace("__VALUE__", element),
);
await writeFile(path, bytes);
- const output = await cli.run({
+ const output = await runFileCli(cli, {
arguments: ["inspect-keyed-archive", path, "--json"],
- environment: { HOME: root, USERPROFILE: root, REA_LOG_LEVEL: "silent" },
+ environment: { REA_LOG_LEVEL: "silent" },
});
expect(output.exitCode).toBe(1);
expect(output.json).toMatchObject({