chore: merge main into PR #2801
This commit is contained in:
@@ -67,3 +67,40 @@ cliTest(
|
||||
expect(session.isError, JSON.stringify(session)).not.toBe(true);
|
||||
},
|
||||
);
|
||||
|
||||
cliTest(
|
||||
"rejects a file URL path field without resolving an invented local path",
|
||||
async ({ cli }) => {
|
||||
const root = await createTestTempDirectory("rea-electron-file-url-");
|
||||
const application = join(root, "main.js");
|
||||
await writeFile(application, "module.exports = {};\n");
|
||||
const response = await cli.run({
|
||||
arguments: [
|
||||
"capture-electron-scenario",
|
||||
JSON.stringify({
|
||||
executable_path: "file:///opt/electron",
|
||||
application_path: application,
|
||||
}),
|
||||
"--format",
|
||||
"json",
|
||||
],
|
||||
environment: { REA_LOG_LEVEL: "silent" },
|
||||
});
|
||||
expect(response.exitCode).toBe(1);
|
||||
expect(response.json).toMatchObject({
|
||||
code: "invalid_request",
|
||||
details: {
|
||||
issues: [
|
||||
{
|
||||
path: ["executable_path"],
|
||||
message: expect.stringContaining(
|
||||
"must be absolute local filesystem paths",
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(response.stdout).not.toContain("ENOENT");
|
||||
expect(response.stdout).not.toContain("file:/opt/electron");
|
||||
},
|
||||
);
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
import { join } from "node:path";
|
||||
|
||||
import { expect } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
import { analyzeJavaScriptDirectory } from "../../support/cli/javascriptApplication.js";
|
||||
import { writeFixtureFiles } from "../../support/javascriptApplicationFixture.js";
|
||||
|
||||
cliTest.for(["CLI", "stdio MCP"] as const)(
|
||||
"retains configuration sources consumed by member access through %s",
|
||||
async (surface, { cli, processes }) => {
|
||||
const root = await createTestTempDirectory("rea-config-reads-");
|
||||
await writeFixtureFiles(root, {
|
||||
"entry.mjs": [
|
||||
"const length = process.env.REA_ENDPOINT.length;",
|
||||
"const endpoint = process.env.REA_ENDPOINT;",
|
||||
"const argumentLength = process.argv[2].length;",
|
||||
"const mode = process.argv[3].trim();",
|
||||
"const optional = process.env.REA_MISSING?.length;",
|
||||
"function shadow(process) { return process.env.LOCAL.length + process.argv[2].length; }",
|
||||
'const local = { env: { FAKE: "fake" }, argv: [0, 1, "abc"] };',
|
||||
'const control = shadow({ env: { LOCAL: "local" }, argv: [0, 1, "abc"] });',
|
||||
"console.log(JSON.stringify([length, endpoint, argumentLength, mode, optional, control, local.env.FAKE.length]));",
|
||||
].join("\n"),
|
||||
});
|
||||
const control = await processes.run(
|
||||
process.execPath,
|
||||
[join(root, "entry.mjs"), "abc", " mode "],
|
||||
{ env: { REA_ENDPOINT: "endpoint" }, timeoutMs: 15_000 },
|
||||
);
|
||||
expect(control.exitCode, control.stderr).toBe(0);
|
||||
expect(JSON.parse(control.stdout)).toEqual([
|
||||
8,
|
||||
"endpoint",
|
||||
3,
|
||||
"mode",
|
||||
null,
|
||||
8,
|
||||
4,
|
||||
]);
|
||||
const graph = (await analyzeJavaScriptDirectory(surface, cli, root))
|
||||
.semantic_graph;
|
||||
const sources = graph.nodes.filter((node) => node.kind === "config-source");
|
||||
expect(
|
||||
sources
|
||||
.map((node) => [node.properties.source_kind, node.properties.key])
|
||||
.sort(),
|
||||
).toEqual([
|
||||
["argv", "2"],
|
||||
["argv", "3"],
|
||||
["environment", "REA_ENDPOINT"],
|
||||
["environment", "REA_ENDPOINT"],
|
||||
["environment", "REA_MISSING"],
|
||||
]);
|
||||
expect(sources.every((node) => node.properties.value === null)).toBe(true);
|
||||
const endpoint = graph.nodes.find(
|
||||
(node) => node.kind === "binding" && node.label === "endpoint",
|
||||
);
|
||||
expect(endpoint).toBeDefined();
|
||||
for (const source of sources) {
|
||||
const bindingTargets = graph.relations
|
||||
.filter((relation) => relation.source_node_id === source.node_id)
|
||||
.flatMap((relation) =>
|
||||
graph.nodes.filter(
|
||||
(node) =>
|
||||
node.node_id === relation.target_node_id &&
|
||||
node.kind === "binding",
|
||||
),
|
||||
);
|
||||
expect(bindingTargets.map((node) => node.node_id)).toEqual(
|
||||
source.identity.source_range?.start.line === 2
|
||||
? [endpoint?.node_id]
|
||||
: [],
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,232 @@
|
||||
import { createServer, type Socket } from "node:net";
|
||||
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { CdpBrowserProvider } from "../../../src/browser/CdpBrowserProvider.js";
|
||||
import { openCdpEndpoint } from "../../../src/browser/CdpTargetSession.js";
|
||||
import { AnalysisError } from "../../../src/domain/analysisErrorBase.js";
|
||||
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
|
||||
import {
|
||||
browserObservationEndpointSchema,
|
||||
inspectWebPageInputSchema,
|
||||
listBrowserTargetsInputSchema,
|
||||
} from "../../../src/domain/browserObservation.js";
|
||||
import { startFakeCdpBrowser } from "../../fixtures/fakeCdpBrowser.js";
|
||||
import { trackBrowser } from "./cdpBrowserProvider.support.js";
|
||||
|
||||
describe("CdpBrowserProvider: browser socket without HTTP discovery", () => {
|
||||
it("discovers and inspects a page through one browser socket", async () => {
|
||||
const browser = await startFakeCdpBrowser();
|
||||
trackBrowser(browser);
|
||||
const provider = new CdpBrowserProvider();
|
||||
const throughHttp = await provider.listTargets(
|
||||
listBrowserTargetsInputSchema.parse({ cdp_endpoint: browser.endpoint }),
|
||||
);
|
||||
if (!throughHttp.ok) throw throughHttp.error;
|
||||
const httpRequests = browser.httpRequests.length;
|
||||
const openedBefore = browser.openedConnectionCount();
|
||||
|
||||
const listed = await provider.listTargets(
|
||||
listBrowserTargetsInputSchema.parse({
|
||||
cdp_endpoint: browser.browserWebSocketUrl,
|
||||
}),
|
||||
);
|
||||
if (!listed.ok) throw listed.error;
|
||||
expect(listed.value.targets).toEqual(throughHttp.value.targets);
|
||||
expect(listed.value.excluded).toEqual(throughHttp.value.excluded);
|
||||
expect(listed.value.browser).toEqual({
|
||||
...throughHttp.value.browser,
|
||||
revision: "@fake-revision",
|
||||
});
|
||||
|
||||
const commandsBefore = browser.commands.length;
|
||||
const inspected = await provider.inspectPage(
|
||||
inspectWebPageInputSchema.parse({
|
||||
cdp_endpoint: browser.browserWebSocketUrl,
|
||||
target_id: "allowed-page",
|
||||
observation_ms: 0,
|
||||
}),
|
||||
);
|
||||
if (!inspected.ok) throw inspected.error;
|
||||
expect(inspected.value.target.origin).toBe(browser.allowedOrigin);
|
||||
expect(
|
||||
browser.commands
|
||||
.slice(commandsBefore, commandsBefore + 3)
|
||||
.map(({ method, params }) => ({ method, params })),
|
||||
).toEqual([
|
||||
{ method: "Browser.getVersion", params: {} },
|
||||
{ method: "Target.getTargets", params: {} },
|
||||
{
|
||||
method: "Target.attachToTarget",
|
||||
params: { targetId: "allowed-page", flatten: true },
|
||||
},
|
||||
]);
|
||||
expect(browser.httpRequests).toHaveLength(httpRequests);
|
||||
expect(browser.openedConnectionCount()).toBe(openedBefore + 2);
|
||||
await vi.waitFor(() => expect(browser.activeConnectionCount()).toBe(0));
|
||||
});
|
||||
});
|
||||
|
||||
describe("CdpBrowserProvider: browser socket failures and cleanup", () => {
|
||||
it("closes an unadopted browser socket when the target is missing", async () => {
|
||||
const browser = await startFakeCdpBrowser();
|
||||
trackBrowser(browser);
|
||||
const result = await new CdpBrowserProvider().inspectPage(
|
||||
inspectWebPageInputSchema.parse({
|
||||
cdp_endpoint: browser.browserWebSocketUrl,
|
||||
target_id: "missing",
|
||||
observation_ms: 0,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result).toMatchObject({
|
||||
ok: false,
|
||||
error: { _tag: "BrowserObservationError", reason: "target_not_found" },
|
||||
});
|
||||
expect(browser.commands.map(({ method }) => method)).toEqual([
|
||||
"Browser.getVersion",
|
||||
"Target.getTargets",
|
||||
]);
|
||||
await vi.waitFor(() => expect(browser.activeConnectionCount()).toBe(0));
|
||||
});
|
||||
|
||||
it("rejects malformed browser-socket discovery and closes the socket", async () => {
|
||||
const browser = await startFakeCdpBrowser({
|
||||
commandResult: ({ method }) =>
|
||||
method === "Browser.getVersion"
|
||||
? { product: "FakeChrome/1.0" }
|
||||
: undefined,
|
||||
});
|
||||
trackBrowser(browser);
|
||||
const result = await new CdpBrowserProvider().listTargets(
|
||||
listBrowserTargetsInputSchema.parse({
|
||||
cdp_endpoint: browser.browserWebSocketUrl,
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
_tag: "BrowserObservationError",
|
||||
operation: "list_browser_targets",
|
||||
reason: "invalid_endpoint_response",
|
||||
},
|
||||
});
|
||||
await vi.waitFor(() => expect(browser.activeConnectionCount()).toBe(0));
|
||||
});
|
||||
|
||||
it("reports a refused browser socket as unreachable", async () => {
|
||||
const browser = await startFakeCdpBrowser();
|
||||
trackBrowser(browser);
|
||||
const result = await new CdpBrowserProvider().listTargets(
|
||||
listBrowserTargetsInputSchema.parse({
|
||||
cdp_endpoint: browser.browserWebSocketUrl.replace(
|
||||
/fake$/u,
|
||||
"not-this-browser",
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
_tag: "BrowserObservationError",
|
||||
reason: "endpoint_unreachable",
|
||||
},
|
||||
});
|
||||
expect(JSON.stringify(result)).not.toContain("not-this-browser");
|
||||
});
|
||||
|
||||
it("cancels browser-socket discovery and releases the socket", async () => {
|
||||
const browser = await startFakeCdpBrowser({
|
||||
hangOnMethod: "Target.getTargets",
|
||||
});
|
||||
trackBrowser(browser);
|
||||
const controller = new AbortController();
|
||||
const pending = new CdpBrowserProvider().inspectPage(
|
||||
inspectWebPageInputSchema.parse({
|
||||
cdp_endpoint: browser.browserWebSocketUrl,
|
||||
target_id: "allowed-page",
|
||||
observation_ms: 0,
|
||||
}),
|
||||
{ signal: controller.signal },
|
||||
);
|
||||
await vi.waitFor(() =>
|
||||
expect(browser.commands.map(({ method }) => method)).toContain(
|
||||
"Target.getTargets",
|
||||
),
|
||||
);
|
||||
controller.abort();
|
||||
|
||||
expect(await pending).toMatchObject({
|
||||
ok: false,
|
||||
error: { _tag: "AnalysisCancelledError", operation: "inspect_web_page" },
|
||||
});
|
||||
expect(browser.commands.map(({ method }) => method)).not.toContain(
|
||||
"Target.attachToTarget",
|
||||
);
|
||||
await vi.waitFor(() => expect(browser.activeConnectionCount()).toBe(0));
|
||||
});
|
||||
});
|
||||
|
||||
/** Expect a discovery timeout that projects publicly as a provider timeout. */
|
||||
const expectDiscoveryTimeout = async (url: string): Promise<void> => {
|
||||
let failure: unknown;
|
||||
try {
|
||||
await openCdpEndpoint(
|
||||
browserObservationEndpointSchema.parse(url),
|
||||
"list_browser_targets",
|
||||
undefined,
|
||||
50,
|
||||
);
|
||||
} catch (cause: unknown) {
|
||||
failure = cause;
|
||||
}
|
||||
expect(failure).toMatchObject({
|
||||
_tag: "BrowserObservationError",
|
||||
reason: "timeout",
|
||||
});
|
||||
if (!(failure instanceof AnalysisError))
|
||||
throw new Error("Expected a typed discovery failure");
|
||||
expect(projectAnalysisError(failure)).toMatchObject({
|
||||
code: "provider_timeout",
|
||||
category: "timeout",
|
||||
});
|
||||
};
|
||||
|
||||
describe("CdpBrowserProvider: browser socket discovery deadline", () => {
|
||||
it("times out a discovery reply that never arrives and closes the socket", async () => {
|
||||
const browser = await startFakeCdpBrowser({
|
||||
hangOnMethod: "Target.getTargets",
|
||||
});
|
||||
trackBrowser(browser);
|
||||
await expectDiscoveryTimeout(browser.browserWebSocketUrl);
|
||||
await vi.waitFor(() => expect(browser.activeConnectionCount()).toBe(0));
|
||||
});
|
||||
|
||||
it("times out a WebSocket handshake that never completes", async () => {
|
||||
const sockets = new Set<Socket>();
|
||||
// Read the upgrade request but never answer it; reading lets the
|
||||
// client's close be observed here.
|
||||
const server = createServer((socket) => {
|
||||
sockets.add(socket);
|
||||
socket.on("close", () => sockets.delete(socket));
|
||||
socket.resume();
|
||||
});
|
||||
await new Promise<void>((resolve) =>
|
||||
server.listen(0, "127.0.0.1", resolve),
|
||||
);
|
||||
const address = server.address();
|
||||
if (address === null || typeof address === "string")
|
||||
throw new Error("Expected a TCP listener address");
|
||||
try {
|
||||
await expectDiscoveryTimeout(
|
||||
`ws://127.0.0.1:${String(address.port)}/devtools/browser/stalled`,
|
||||
);
|
||||
await vi.waitFor(() => expect(sockets.size).toBe(0));
|
||||
} finally {
|
||||
for (const socket of sockets) socket.destroy();
|
||||
await new Promise<void>((resolve) => server.close(() => resolve()));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -3,6 +3,7 @@ import { createServer } from "node:http";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { CdpBrowserProvider } from "../../../src/browser/CdpBrowserProvider.js";
|
||||
import { listBrowserTargetsInputSchema } from "../../../src/domain/browserObservation.js";
|
||||
|
||||
describe("CDP target inventory", () => {
|
||||
it("returns every allowed target within the bounded discovery payload", async () => {
|
||||
@@ -51,10 +52,12 @@ describe("CDP target inventory", () => {
|
||||
port = address.port;
|
||||
const endpoint = `http://127.0.0.1:${String(port)}`;
|
||||
|
||||
const result = await new CdpBrowserProvider().listTargets({
|
||||
cdp_endpoint: endpoint,
|
||||
allowed_origins: ["https://allowed.example"],
|
||||
});
|
||||
const result = await new CdpBrowserProvider().listTargets(
|
||||
listBrowserTargetsInputSchema.parse({
|
||||
cdp_endpoint: endpoint,
|
||||
allowed_origins: ["https://allowed.example"],
|
||||
}),
|
||||
);
|
||||
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.targets).toHaveLength(targets.length);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { createServer } from "node:http";
|
||||
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { fetchWebSourceMaps } from "../../../src/browser/WebSourceMapFetcher.js";
|
||||
import { analyzeWebBundleInputSchema } from "../../../src/domain/webBundleAnalysis.js";
|
||||
|
||||
it("retains unshadowed optional require dependencies from HTTP source-map originals", async () => {
|
||||
const source = [
|
||||
'require("./normal.cjs");',
|
||||
'require?.("./optional.cjs");',
|
||||
'function local(require) { require?.("./shadowed.cjs"); }',
|
||||
"require?.(selectedModule);",
|
||||
].join("\n");
|
||||
const text = JSON.stringify({
|
||||
version: 3,
|
||||
names: [],
|
||||
mappings: "AAAA",
|
||||
sources: ["main.cjs"],
|
||||
sourcesContent: [source],
|
||||
});
|
||||
const server = createServer((_request, response) => response.end(text));
|
||||
try {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
server.once("error", reject);
|
||||
server.listen(0, "127.0.0.1", resolve);
|
||||
});
|
||||
const address = server.address();
|
||||
if (address === null || typeof address === "string")
|
||||
throw new TypeError("Expected a TCP listener address");
|
||||
const origin = `http://127.0.0.1:${String(address.port)}`;
|
||||
const url = `${origin}/app.js.map`;
|
||||
const result = await fetchWebSourceMaps(
|
||||
[{ scriptKey: `scr_${"1".repeat(64)}`, declaredUrl: url, fetchUrl: url }],
|
||||
analyzeWebBundleInputSchema.parse({
|
||||
cdp_endpoint: origin,
|
||||
target_id: "fixture",
|
||||
allowed_origins: [origin],
|
||||
fetch_source_maps: true,
|
||||
}),
|
||||
);
|
||||
expect(result.items[0]).toMatchObject({
|
||||
status: "included",
|
||||
artifact: {
|
||||
text,
|
||||
bytes: Buffer.byteLength(text),
|
||||
sha256: createHash("sha256").update(text).digest("hex"),
|
||||
},
|
||||
original_sources: [{ artifact: { text: source } }],
|
||||
original_module_edges: ["./normal.cjs", "./optional.cjs"].map(
|
||||
(specifier) => ({
|
||||
from_source: `${origin}/main.cjs`,
|
||||
kind: "require",
|
||||
specifier,
|
||||
resolved_source: new URL(specifier, origin).href,
|
||||
}),
|
||||
),
|
||||
});
|
||||
} finally {
|
||||
server.closeAllConnections();
|
||||
if (server.listening)
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
server.close((error) =>
|
||||
error === undefined ? resolve() : reject(error),
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -810,7 +810,6 @@ describe("web source-map sourcesContent validation", () => {
|
||||
it.each([
|
||||
["a scalar sourcesContent value", { sourcesContent: "source" }],
|
||||
["a non-string, non-null source entry", { sourcesContent: [42] }],
|
||||
["a sourcesContent array with the wrong length", { sourcesContent: [] }],
|
||||
])("reports %s as invalid", async (_description, content) => {
|
||||
const result = await fetchWebSourceMaps([request], input(), undefined, {
|
||||
fetch: () =>
|
||||
@@ -841,6 +840,50 @@ describe("web source-map sourcesContent validation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
["shorter", ["import './a.ts';"]],
|
||||
["longer", ["import './a.ts';", null, "unused trailing content"]],
|
||||
])(
|
||||
"keeps every source declaration when sourcesContent is %s than sources",
|
||||
async (_length, sourcesContent) => {
|
||||
const result = await fetchWebSourceMaps([request], input(), undefined, {
|
||||
fetch: () =>
|
||||
Promise.resolve(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
version: 3,
|
||||
sources: ["a.ts", "b.ts"],
|
||||
sourcesContent,
|
||||
names: [],
|
||||
mappings: "",
|
||||
}),
|
||||
{ status: 200 },
|
||||
),
|
||||
),
|
||||
});
|
||||
|
||||
expect(result.items[0]).toMatchObject({
|
||||
status: "included",
|
||||
limitation: null,
|
||||
original_sources: [
|
||||
{
|
||||
source_index: 0,
|
||||
declaration_index: 0,
|
||||
source: `${origin}/assets/a.ts`,
|
||||
artifact: { text: "import './a.ts';" },
|
||||
},
|
||||
{
|
||||
source_index: 1,
|
||||
declaration_index: 1,
|
||||
source: `${origin}/assets/b.ts`,
|
||||
artifact: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(result.items[0]?.original_sources).toHaveLength(2);
|
||||
},
|
||||
);
|
||||
|
||||
it("accepts null source-map source contents", async () => {
|
||||
const result = await fetchWebSourceMaps([request], input(), undefined, {
|
||||
fetch: () =>
|
||||
|
||||
@@ -183,6 +183,54 @@ it(
|
||||
INTEGRATION_TEST_TIMEOUT_MS,
|
||||
);
|
||||
|
||||
it(
|
||||
"browser CLI attaches through a browser socket and records it redacted",
|
||||
async () => {
|
||||
const browser = await startFakeCdpBrowser();
|
||||
browsers.push(browser);
|
||||
const inspected = await runCli(
|
||||
[
|
||||
"inspect-web-page",
|
||||
browser.browserWebSocketUrl,
|
||||
"allowed-page",
|
||||
"--observation-ms",
|
||||
"0",
|
||||
"--json",
|
||||
],
|
||||
process.env,
|
||||
);
|
||||
expect(inspected).toMatchObject({
|
||||
operation: "inspect_web_page",
|
||||
parameters: {
|
||||
cdp_endpoint: browser.browserWebSocketUrl.replace(
|
||||
/fake$/u,
|
||||
"[REDACTED]",
|
||||
),
|
||||
},
|
||||
normalized_result: { target: { target_id: "allowed-page" } },
|
||||
});
|
||||
expect(JSON.stringify(inspected)).not.toContain("/devtools/browser/fake");
|
||||
|
||||
const refused = await runCli(
|
||||
[
|
||||
"list-browser-targets",
|
||||
browser.browserWebSocketUrl.replace(/fake$/u, "not-this-browser"),
|
||||
"--json",
|
||||
],
|
||||
process.env,
|
||||
);
|
||||
expect(refused).toMatchObject({
|
||||
code: "provider_unavailable",
|
||||
details: {
|
||||
operation: "list_browser_targets",
|
||||
reason: "endpoint_unreachable",
|
||||
},
|
||||
});
|
||||
expect(JSON.stringify(refused)).not.toContain("not-this-browser");
|
||||
},
|
||||
INTEGRATION_TEST_TIMEOUT_MS,
|
||||
);
|
||||
|
||||
describe("scenario comparison CLI diagnostics", () => {
|
||||
const rule = {
|
||||
rule_id: "domain",
|
||||
|
||||
@@ -290,7 +290,7 @@ cliTest("uninstall names each retained skill directory", async ({ cli }) => {
|
||||
for (const [client, directory] of [
|
||||
["shared", shared],
|
||||
["claude_code", claude],
|
||||
]) {
|
||||
] as const) {
|
||||
expect(skill?.detail).toContain(
|
||||
`${client} (${directory}): retained (Skill manifest is not REA-owned.)`,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
|
||||
import { expect } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
|
||||
const packageSchema = z.object({ version: z.string() });
|
||||
|
||||
// Node's Windows home lookup throws for an empty USERPROFILE, so a dependency
|
||||
// that resolves the home during import used to stop every command there.
|
||||
cliTest("starts when the selected home is empty", async ({ cli }) => {
|
||||
const { version } = packageSchema.parse(
|
||||
JSON.parse(await readFile("package.json", "utf8")),
|
||||
);
|
||||
const cwd = await createTestTempDirectory("rea-empty-home-startup-");
|
||||
const environment = { HOME: "", USERPROFILE: "" };
|
||||
|
||||
const reported = await cli.run({
|
||||
arguments: ["--version"],
|
||||
cwd,
|
||||
environment,
|
||||
});
|
||||
expect(reported.stderr).toBe("");
|
||||
expect(reported.exitCode).toBe(0);
|
||||
expect(reported.stdout.trim()).toBe(version);
|
||||
|
||||
const help = await cli.run({ arguments: ["--help"], cwd, environment });
|
||||
expect(help.stderr).not.toContain("uv_os_homedir");
|
||||
expect(help.exitCode).toBe(0);
|
||||
});
|
||||
@@ -0,0 +1,190 @@
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { describe, expect } from "vitest";
|
||||
|
||||
import {
|
||||
createHistoricalSourceManifest,
|
||||
parseHistoricalSourceGraph,
|
||||
} from "../../../src/domain/referenceSourceGraph.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
|
||||
describe.skipIf(process.platform === "win32")(
|
||||
"compiled historical-source summaries",
|
||||
() => {
|
||||
cliTest(
|
||||
"selects a committed summary without changing complete output",
|
||||
async ({ cli }) => {
|
||||
const root = await createTestTempDirectory("rea-reference-summary-");
|
||||
await mkdir(join(root, "src", "nested"), { recursive: true });
|
||||
await Promise.all([
|
||||
writeFile(join(root, "package.json"), '{"name":"fixture"}\n'),
|
||||
writeFile(
|
||||
join(root, "src", "main.js"),
|
||||
'import "./nested/value.js";\n',
|
||||
),
|
||||
writeFile(
|
||||
join(root, "src", "nested", "value.js"),
|
||||
"export const value = 1;\n",
|
||||
),
|
||||
writeFile(join(root, "\uE000.js"), "export const first = 1;\n"),
|
||||
writeFile(join(root, "\u{10000}.js"), "export const last = 2;\n"),
|
||||
]);
|
||||
const run = (...options: string[]) =>
|
||||
cli.run({
|
||||
arguments: ["import-reference-source", root, "--json", ...options],
|
||||
cwd: root,
|
||||
});
|
||||
const complete = await run();
|
||||
expect(complete.exitCode).toBe(0);
|
||||
const graph = parseHistoricalSourceGraph(complete.json);
|
||||
expect((await run("--detail", "full")).stdout).toBe(complete.stdout);
|
||||
for (const depth of [undefined, 0, 1, 10]) {
|
||||
const result = await run(
|
||||
"--detail",
|
||||
"summary",
|
||||
...(depth === undefined ? [] : ["--outline-depth", String(depth)]),
|
||||
);
|
||||
expect(result.exitCode).toBe(0);
|
||||
const selected = graph.entries.filter(
|
||||
(entry) => entry.path.split("/").length <= (depth ?? 2),
|
||||
);
|
||||
expect(result.json).toMatchObject({
|
||||
schema: "HistoricalSourceSummary",
|
||||
authority: graph.authority,
|
||||
root_alias: graph.root_alias,
|
||||
manifest: createHistoricalSourceManifest(graph),
|
||||
inventory_state: graph.inventory_state,
|
||||
provenance: graph.provenance,
|
||||
vcs: graph.vcs,
|
||||
languages: graph.languages,
|
||||
manifests: graph.manifests,
|
||||
counts: {
|
||||
entries: 7,
|
||||
files: 5,
|
||||
directories: 2,
|
||||
symlinks: 0,
|
||||
relationships: 1,
|
||||
parse_failures: 0,
|
||||
exclusions: 0,
|
||||
},
|
||||
outline: {
|
||||
depth: depth ?? 2,
|
||||
entries: selected.map(({ path, kind }) =>
|
||||
expect.objectContaining({ path, kind }),
|
||||
),
|
||||
omitted_entry_count: graph.entries.length - selected.length,
|
||||
},
|
||||
});
|
||||
expect(result.json).not.toHaveProperty("relationships");
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
cliTest(
|
||||
"retains exclusions and parse coverage independently of a hidden outline",
|
||||
async ({ cli }) => {
|
||||
const root = await createTestTempDirectory(
|
||||
"rea-reference-partial-summary-",
|
||||
);
|
||||
await Promise.all([
|
||||
writeFile(join(root, ".gitignore"), "ignored.txt\n"),
|
||||
writeFile(join(root, "ignored.txt"), "ignored\n"),
|
||||
writeFile(join(root, "broken.js"), "export const = ;\n"),
|
||||
]);
|
||||
const result = await cli.run({
|
||||
arguments: [
|
||||
"import-reference-source",
|
||||
root,
|
||||
"--detail",
|
||||
"summary",
|
||||
"--outline-depth",
|
||||
"0",
|
||||
"--json",
|
||||
],
|
||||
cwd: root,
|
||||
});
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.json).toMatchObject({
|
||||
inventory_state: "partial",
|
||||
counts: { parse_failures: 1, exclusions: 1 },
|
||||
exclusions: [
|
||||
{
|
||||
path: "ignored.txt",
|
||||
reason: "project-ignored",
|
||||
pattern: "ignored.txt",
|
||||
},
|
||||
],
|
||||
outline: { depth: 0, entries: [], omitted_entry_count: 2 },
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
describe("compiled historical-source summary input boundaries", () => {
|
||||
cliTest(
|
||||
"documents detail and depth in public command help",
|
||||
async ({ cli }) => {
|
||||
const result = await cli.run({
|
||||
arguments: ["import-reference-source", "--help"],
|
||||
});
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain("--detail");
|
||||
expect(result.stdout).toContain("--outline-depth");
|
||||
expect(result.stdout).toContain("requires --detail summary");
|
||||
},
|
||||
);
|
||||
|
||||
for (const options of [
|
||||
["--detail", "summry"],
|
||||
["--detail", "summary", "--outline-depth", "-1"],
|
||||
["--detail", "summary", "--outline-depth", "1.5"],
|
||||
["--detail", "summary", "--outline-depth", "NaN"],
|
||||
["--detail", "summary", "--outline-depth", "9007199254740992"],
|
||||
["--outline-depth", "1"],
|
||||
["--detail", "full", "--outline-depth", "1"],
|
||||
]) {
|
||||
cliTest(`rejects ${options.join(" ")}`, async ({ cli }) => {
|
||||
const root = await createTestTempDirectory(
|
||||
"rea-reference-summary-input-",
|
||||
);
|
||||
const result = await cli.run({
|
||||
arguments: ["import-reference-source", root, ...options, "--json"],
|
||||
cwd: root,
|
||||
});
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.stdout).not.toContain("HistoricalSourceGraph");
|
||||
expect(result.stdout).not.toContain("HistoricalSourceSummary");
|
||||
expect(result.stdout).toMatch(/detail|outline/u);
|
||||
});
|
||||
}
|
||||
|
||||
cliTest(
|
||||
"preserves the missing-root failure in summary mode",
|
||||
async ({ cli }) => {
|
||||
const root = await createTestTempDirectory(
|
||||
"rea-reference-summary-missing-",
|
||||
);
|
||||
const result = await cli.run({
|
||||
arguments: [
|
||||
"import-reference-source",
|
||||
join(root, "missing"),
|
||||
"--detail",
|
||||
"summary",
|
||||
"--json",
|
||||
],
|
||||
cwd: root,
|
||||
});
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.json).toMatchObject({
|
||||
error: "Import failed",
|
||||
category: "invalid_input",
|
||||
message: expect.stringContaining(
|
||||
"Reference source root could not be resolved",
|
||||
),
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -135,7 +135,6 @@ it("retains every source declared by every included local source map", async ()
|
||||
it.each([
|
||||
["a non-array sourcesContent value", { sourcesContent: "source" }],
|
||||
["a non-string, non-null source entry", { sourcesContent: [42] }],
|
||||
["a source-content array with the wrong length", { sourcesContent: [] }],
|
||||
])(
|
||||
"reports %s as an invalid local source map",
|
||||
async (_description, content) => {
|
||||
@@ -210,6 +209,51 @@ it("accepts omitted and explicitly null source-map source contents", async () =>
|
||||
expect(result.graph.coverage.status).toBe("complete");
|
||||
});
|
||||
|
||||
it.each([
|
||||
["shorter", ["export const answer = 42;"]],
|
||||
["longer", ["export const answer = 42;", null, "unused trailing content"]],
|
||||
])(
|
||||
"keeps every source declaration when sourcesContent is %s than sources",
|
||||
async (length, sourcesContent) => {
|
||||
const root = await createTestTempDirectory(
|
||||
`rea-javascript-${length}-source-content-`,
|
||||
);
|
||||
await writeFile(
|
||||
join(root, "bundle.js.map"),
|
||||
JSON.stringify({
|
||||
version: 3,
|
||||
sources: ["a.ts", "b.ts"],
|
||||
sourcesContent,
|
||||
names: [],
|
||||
mappings: "AAAA;ACAA",
|
||||
}),
|
||||
);
|
||||
|
||||
const result = await reconstructJavaScriptArtifact({ input_path: root });
|
||||
const originals = result.graph.nodes.filter(
|
||||
({ identity }) => identity.strategy === "source-map-original",
|
||||
);
|
||||
|
||||
expect(
|
||||
originals
|
||||
.map(({ identity, observations }) => ({
|
||||
original_source:
|
||||
"original_source" in identity ? identity.original_source : null,
|
||||
source_index: observations[0]?.properties.source_index,
|
||||
content_available: observations[0]?.properties.content_available,
|
||||
}))
|
||||
.sort(
|
||||
(left, right) =>
|
||||
Number(left.source_index) - Number(right.source_index),
|
||||
),
|
||||
).toEqual([
|
||||
{ original_source: "a.ts", source_index: 0, content_available: true },
|
||||
{ original_source: "b.ts", source_index: 1, content_available: false },
|
||||
]);
|
||||
expect(result.graph.coverage.status).toBe("complete");
|
||||
},
|
||||
);
|
||||
|
||||
it("retains unnamed source declarations without shifting later source evidence", async () => {
|
||||
const root = await createTestTempDirectory("rea-javascript-unnamed-source-");
|
||||
const text = JSON.stringify({
|
||||
|
||||
@@ -424,6 +424,47 @@ it("delivers the source-map response URL through authenticated MCP Evidence", as
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("records a browser-socket endpoint redacted and reconciles its Evidence", async () => {
|
||||
const browser = await startFakeCdpBrowser();
|
||||
browsers.push(browser);
|
||||
const connected = await connectBrowser();
|
||||
const tool = (await connected.client.listTools()).tools.find(
|
||||
({ name }) => name === "inspect_web_page",
|
||||
);
|
||||
expect(tool?.inputSchema.properties?.cdp_endpoint).toMatchObject({
|
||||
description: expect.stringContaining("/devtools/browser/ID"),
|
||||
});
|
||||
const inspected = await connected.client.callTool({
|
||||
name: "inspect_web_page",
|
||||
arguments: {
|
||||
cdp_endpoint: browser.browserWebSocketUrl,
|
||||
target_id: "allowed-page",
|
||||
observation_ms: 0,
|
||||
include_script_sources: true,
|
||||
},
|
||||
});
|
||||
expect(inspected.isError).not.toBe(true);
|
||||
expect(inspected.structuredContent).toMatchObject({
|
||||
parameters: {
|
||||
cdp_endpoint: browser.browserWebSocketUrl.replace(/fake$/u, "[REDACTED]"),
|
||||
},
|
||||
});
|
||||
expect(JSON.stringify(inspected.structuredContent)).not.toContain(
|
||||
"/devtools/browser/fake",
|
||||
);
|
||||
const reconciled = await connected.client.callTool({
|
||||
name: "reconcile_javascript_runtime",
|
||||
arguments: {
|
||||
static_layers: JAVASCRIPT_RUNTIME_RECONCILIATION_EXAMPLE.static_layers,
|
||||
runtime_observations: [evidenceFor(inspected.structuredContent)],
|
||||
},
|
||||
});
|
||||
expect(reconciled.isError).not.toBe(true);
|
||||
expect(reconciled.structuredContent).toMatchObject({
|
||||
normalized_result: { summary: { runtime_scripts: 1 } },
|
||||
});
|
||||
});
|
||||
|
||||
it("does not attach to a target outside the request's allowed origin scope", async () => {
|
||||
const browser = await startFakeCdpBrowser();
|
||||
browsers.push(browser);
|
||||
|
||||
@@ -104,7 +104,16 @@ const fixturePort = (): AnalysisOperationPort => ({
|
||||
"0x11": "_OBJC_CLASS_$_Fixture",
|
||||
"0x12": "_OBJC_PROTOCOL_$_FixtureDelegate",
|
||||
"0x13": "entry",
|
||||
}),
|
||||
}).map((entry) => ({
|
||||
...entry,
|
||||
symbol: {
|
||||
primary: true,
|
||||
dynamic: false,
|
||||
external: false,
|
||||
type: "label",
|
||||
source: "analysis",
|
||||
},
|
||||
})),
|
||||
),
|
||||
);
|
||||
case "decode_interface_builder":
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
} from "./ghidraMcpHarness.js";
|
||||
import { spawn } from "node:child_process";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||
import { GhidraClient } from "../../../src/ghidra/GhidraClient.js";
|
||||
|
||||
@@ -225,6 +225,79 @@ it("retains native inventory facts from captured Apple tool output", async () =>
|
||||
});
|
||||
});
|
||||
|
||||
it("reports a renamed re-export once under its exported name", async () => {
|
||||
const client = new NativeMacOSProvider(
|
||||
{},
|
||||
new FixtureRunner({
|
||||
"dyld_info:-exports": await fixture(
|
||||
"dyld-inventory/renamed-reexports.txt",
|
||||
),
|
||||
nm: "_foo_renamed\n_own\n",
|
||||
}),
|
||||
"darwin",
|
||||
).createClient(machoTarget("/private/fixture"));
|
||||
const execution = await client.execute("inspect_macho", {});
|
||||
if (!execution.ok) throw execution.error;
|
||||
expect(execution.value.result).toMatchObject({
|
||||
exports: {
|
||||
items: [
|
||||
{
|
||||
name: "_foo_renamed",
|
||||
address: null,
|
||||
weak: null,
|
||||
reexport: true,
|
||||
source: "libfoo",
|
||||
},
|
||||
{ name: "_own", reexport: false, source: null },
|
||||
],
|
||||
limitations: [
|
||||
"Merged nm/dyld_info results may be incomplete for stripped binaries.",
|
||||
"Renamed re-exports are listed under their exported name; the source library's symbol name is not reported.",
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("splits re-export rows at the source library", () => {
|
||||
// dyld_info -exports rows for synthetic dylibs: a source symbol named
|
||||
// `operator()`, and a library whose install name contains ` from `.
|
||||
expect(
|
||||
parseDyldSymbols(
|
||||
[
|
||||
"[re-export] _call_renamed (operator() from libfoo)",
|
||||
"[re-export] _g (from lib from foo)",
|
||||
"[re-export] _nested (from lib (from foo))",
|
||||
].join("\n"),
|
||||
"exports",
|
||||
null,
|
||||
new Set(["_call_renamed", "_g", "_nested"]),
|
||||
),
|
||||
).toEqual([
|
||||
{
|
||||
name: "_call_renamed",
|
||||
address: null,
|
||||
weak: null,
|
||||
reexport: true,
|
||||
source: "libfoo",
|
||||
sourceSymbol: "operator()",
|
||||
},
|
||||
{
|
||||
name: "_g",
|
||||
address: null,
|
||||
weak: null,
|
||||
reexport: true,
|
||||
source: "lib from foo",
|
||||
},
|
||||
{
|
||||
name: "_nested",
|
||||
address: null,
|
||||
weak: null,
|
||||
reexport: true,
|
||||
source: "lib (from foo)",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("retains symbol names containing spaces in dyld inventory rows", () => {
|
||||
expect(
|
||||
parseDyldSymbols(" 0x0000 _entry with space (from fixture)", "imports"),
|
||||
@@ -449,6 +522,25 @@ it("leaves an ambiguous short and literal name to the caller's nm inventory", ()
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("retains unmatched re-export rows when the known export inventory is incomplete", () => {
|
||||
expect(
|
||||
parseDyldSymbols(
|
||||
"[re-export] _g (from libfoo)",
|
||||
"exports",
|
||||
null,
|
||||
new Set(["_own"]),
|
||||
),
|
||||
).toEqual([
|
||||
{
|
||||
name: "_g",
|
||||
address: null,
|
||||
weak: null,
|
||||
reexport: true,
|
||||
source: "libfoo",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("retains annotation parsing without nm name evidence", () => {
|
||||
expect(parseDyldSymbols("0x120 _weak [weak-def]", "exports")).toEqual([
|
||||
{
|
||||
|
||||
Vendored
+3
@@ -28,6 +28,7 @@ export const startFakeCdpBrowser = async (
|
||||
referer: string | undefined;
|
||||
}[] = [];
|
||||
const sockets = new Set<WebSocket>();
|
||||
let openedConnections = 0;
|
||||
let frameTreeReads = 0;
|
||||
let port = 0;
|
||||
const http = createServer((request, response) => {
|
||||
@@ -85,6 +86,7 @@ export const startFakeCdpBrowser = async (
|
||||
});
|
||||
webSockets.on("connection", (socket: WebSocket, request: IncomingMessage) => {
|
||||
const directPage = request.url?.startsWith("/devtools/page/") === true;
|
||||
openedConnections += 1;
|
||||
sockets.add(socket);
|
||||
socket.on("close", () => sockets.delete(socket));
|
||||
socket.on("message", (raw) => {
|
||||
@@ -142,6 +144,7 @@ export const startFakeCdpBrowser = async (
|
||||
allowedOrigin: endpoint,
|
||||
commands,
|
||||
activeConnectionCount: () => sockets.size,
|
||||
openedConnectionCount: () => openedConnections,
|
||||
emitRawMessage(message) {
|
||||
for (const socket of sockets) socket.send(message);
|
||||
},
|
||||
|
||||
+11
@@ -24,6 +24,8 @@ export const resultFor = (
|
||||
return responseBodyResult(options);
|
||||
case "Page.captureScreenshot":
|
||||
return screenshotResult();
|
||||
case "Browser.getVersion":
|
||||
return browserVersionResult();
|
||||
case "Target.getTargets":
|
||||
return { targetInfos: targets(port, options).map(endpointTargetToInfo) };
|
||||
case "Storage.getUsageAndQuota":
|
||||
@@ -66,6 +68,15 @@ export const resultFor = (
|
||||
}
|
||||
};
|
||||
|
||||
/** Chrome's browser-socket reply shape, mirroring the fake's `/json/version`. */
|
||||
const browserVersionResult = () => ({
|
||||
protocolVersion: "1.3",
|
||||
product: "FakeChrome/1.0",
|
||||
revision: "@fake-revision",
|
||||
userAgent: "FakeChrome",
|
||||
jsVersion: "13.0",
|
||||
});
|
||||
|
||||
const attachToTargetResult = (options: FakeOptions) => ({
|
||||
sessionId: options.invalidAttachedSession ? "" : "session-1",
|
||||
});
|
||||
|
||||
+2
@@ -13,6 +13,8 @@ export interface FakeCdpBrowser {
|
||||
readonly commands: readonly FakeCdpCommand[];
|
||||
/** Actual WebSocket connections still held by the wire fixture. */
|
||||
activeConnectionCount(): number;
|
||||
/** WebSocket upgrades accepted over the fixture's lifetime. */
|
||||
openedConnectionCount(): number;
|
||||
/** Deliver actual malformed wire data without bypassing the production transport parser. */
|
||||
emitRawMessage(message: string): void;
|
||||
emitEvent(event: {
|
||||
|
||||
@@ -37,6 +37,19 @@ import rows from `xcrun dyld_info -imports /usr/lib/libobjc.A.dylib`.
|
||||
`xcrun dyld_info -exports /usr/lib/libc++.1.dylib`. These are separate library
|
||||
captures used to check their respective row formats.
|
||||
|
||||
`renamed-reexports.txt` is `xcrun dyld_info -exports` for a dylib that
|
||||
re-exports `_foo` from `libfoo` under the name `_foo_renamed`:
|
||||
|
||||
```sh
|
||||
printf 'int foo(void){return 1;}\n' > /tmp/foo.c
|
||||
printf 'int own(void){return 2;}\n' > /tmp/re.c
|
||||
xcrun clang -dynamiclib /tmp/foo.c -o /tmp/libfoo.dylib -install_name @rpath/libfoo.dylib
|
||||
xcrun clang -dynamiclib /tmp/re.c -o /tmp/libre.dylib -install_name @rpath/libre.dylib \
|
||||
/tmp/libfoo.dylib -Wl,-alias,_foo,_foo_renamed
|
||||
xcrun dyld_info -exports /tmp/libre.dylib
|
||||
xcrun nm -gjU /tmp/libre.dylib
|
||||
```
|
||||
|
||||
`codesign-missing.txt` is stderr from `codesign -d --verbose=4` on a nonexistent
|
||||
path (exit 1). `codesign-unsigned.txt` is stderr from the same command on a copy
|
||||
of the fixture after `codesign --remove-signature` (exit 1). Only the latter is
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
fixture [arm64]:
|
||||
-exports:
|
||||
offset symbol
|
||||
[re-export] _foo_renamed (_foo from libfoo)
|
||||
0x00000308 _own
|
||||
@@ -1,6 +1,13 @@
|
||||
import { execFile } from "node:child_process";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { chmod, copyFile, readFile, symlink, unlink } from "node:fs/promises";
|
||||
import {
|
||||
chmod,
|
||||
copyFile,
|
||||
mkdir,
|
||||
readFile,
|
||||
symlink,
|
||||
unlink,
|
||||
} from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
@@ -24,6 +31,8 @@ it
|
||||
const directory = await createTestTempDirectory("rea-clean-runtime-test-");
|
||||
const launcher = join(directory, "Hopper");
|
||||
const alternate = join(directory, "Hopper-alternate");
|
||||
const procRoot = join(directory, "proc");
|
||||
await mkdir(procRoot);
|
||||
const alternateMode = mode === "alternate launcher";
|
||||
if (alternateMode) {
|
||||
await copyFile("/usr/bin/sleep", launcher);
|
||||
@@ -32,7 +41,10 @@ it
|
||||
}
|
||||
// A rejection must come from the fixture we are about to launch. An
|
||||
// existing Xvfb would otherwise mask a broken executable-identity check.
|
||||
await assertCleanLinuxHopperRuntime(alternateMode ? [launcher] : []);
|
||||
await assertCleanLinuxHopperRuntime(
|
||||
alternateMode ? [launcher] : [],
|
||||
procRoot,
|
||||
);
|
||||
const command = alternateMode ? alternate : process.execPath;
|
||||
const arguments_ = alternateMode ? ["30"] : ["-e", childCode];
|
||||
const parentCode = `
|
||||
@@ -59,6 +71,11 @@ it
|
||||
const { stdout } = await parent;
|
||||
const { pid } = JSON.parse(stdout) as { pid: number };
|
||||
orphanPid = pid;
|
||||
if (alternateMode) {
|
||||
const processEntry = join(procRoot, String(pid));
|
||||
await mkdir(processEntry);
|
||||
await symlink(`/proc/${String(pid)}/exe`, join(processEntry, "exe"));
|
||||
}
|
||||
const { stdout: coordinates } = await execFileAsync("ps", [
|
||||
"-p",
|
||||
String(pid),
|
||||
@@ -92,7 +109,10 @@ it
|
||||
await unlink(alternate);
|
||||
}
|
||||
await expect(
|
||||
assertCleanLinuxHopperRuntime(alternateMode ? [launcher] : []),
|
||||
assertCleanLinuxHopperRuntime(
|
||||
alternateMode ? [launcher] : [],
|
||||
procRoot,
|
||||
),
|
||||
).rejects.toThrow("Clean Linux runner retained a Hopper demo process");
|
||||
// Observation must not terminate the fixture, even though it resembles Xvfb.
|
||||
const { stdout: alive } = await execFileAsync("ps", [
|
||||
|
||||
Reference in New Issue
Block a user