Incorporate the independent query-bearing ESM and cjs-only directory cases from #2031 and #2032 into existing Node-backed CLI/MCP tests. Their production patches are already superseded on main. Make invalid Swift-symbol validation prove it precedes artifact access, and bound the test child so failures retain output before the outer test deadline. Clarify that network API content types project only the type/subtype essence. Validation: module lookup CLI/MCP and native demangle CLI tests pass. A bounded Flameox reproduction passed in under one second; the CI timeout was not reproduced and no provider hang fix is claimed. Co-authored-by: hhang <169027046+xu91102@users.noreply.github.com>
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { copyFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { describe, expect } from "vitest";
|
|
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../../support/cli/cliFixture.js";
|
|
|
|
const environment = {
|
|
REA_LOG_LEVEL: "silent",
|
|
REA_ANALYSIS_PROVIDER: "auto",
|
|
} as const;
|
|
|
|
/** Copy a host program to serve as the evidence-identity artifact. */
|
|
const evidenceTarget = async () => {
|
|
const path = join(await createTestTempDirectory("rea-demangle-"), "tool");
|
|
await copyFile("/usr/bin/true", path);
|
|
return path;
|
|
};
|
|
|
|
describe.skipIf(process.platform !== "darwin")(
|
|
"native Swift demangling CLI with line-terminator characters",
|
|
() => {
|
|
cliTest("keeps a carriage return in the symbol", async ({ cli }) => {
|
|
const result = await cli.run({
|
|
arguments: [
|
|
"demangle-swift",
|
|
await evidenceTarget(),
|
|
"$s4main3FooV",
|
|
"carriage\r",
|
|
"--json",
|
|
],
|
|
environment,
|
|
});
|
|
expect(result.exitCode).toBe(0);
|
|
expect(result.json).toMatchObject({
|
|
normalized_result: {
|
|
symbols: [
|
|
{ input: "$s4main3FooV", output: "main.Foo", status: "demangled" },
|
|
{ input: "carriage\r", output: "carriage\r", status: "unchanged" },
|
|
],
|
|
},
|
|
});
|
|
});
|
|
|
|
cliTest("rejects a symbol spanning lines as input", async ({ cli }) => {
|
|
const missingTarget = join(
|
|
await createTestTempDirectory("rea-demangle-invalid-input-"),
|
|
"absent",
|
|
);
|
|
const result = await cli.run({
|
|
arguments: [
|
|
"demangle-swift",
|
|
missingTarget,
|
|
"$s4main3FooV",
|
|
"$s4main\n3FooV",
|
|
"--json",
|
|
],
|
|
environment,
|
|
timeoutMs: 20_000,
|
|
});
|
|
expect(result.exitCode).not.toBe(0);
|
|
expect(result.json).toMatchObject({ code: "VALIDATION_ERROR" });
|
|
});
|
|
},
|
|
);
|