mirror of
https://github.com/morluto/rea.git
synced 2026-10-31 11:56:12 +00:00
inspect-apple-ips and inspect-pe-imports were the two commands in the binary diagnostics group whose positional target was still a plain string. An empty argument passed CLI validation, was resolved to the working directory, and failed later as a non-file input, unlike their siblings (inspect-elf-notes, inspect-pe-certificates and others) that already reject it at validation. Declare both targets with the shared nonempty, NUL-free local path schema the rest of the file uses. Explicit "." is unchanged. Fixes #7421
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { expect } from "vitest";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../../support/cli/cliFixture.js";
|
|
|
|
cliTest.for(["inspect-apple-ips", "inspect-pe-imports"])(
|
|
"rejects an empty %s target before resolving the working directory",
|
|
async (command, { cli }) => {
|
|
const root = await createTestTempDirectory("rea-empty-diagnostic-target-");
|
|
// docs/cli.md: an empty string never selects the working directory.
|
|
const empty = await cli.run({
|
|
arguments: [command, "", "--json"],
|
|
cwd: root,
|
|
});
|
|
expect(empty.exitCode).not.toBe(0);
|
|
expect(empty.json).toMatchObject({
|
|
code: "VALIDATION_ERROR",
|
|
fieldErrors: [
|
|
expect.objectContaining({ path: "path", code: "too_small" }),
|
|
],
|
|
});
|
|
// Explicit "." still selects the directory, which the inspection refuses.
|
|
const explicit = await cli.run({
|
|
arguments: [command, ".", "--json"],
|
|
cwd: root,
|
|
});
|
|
expect(explicit.exitCode).not.toBe(0);
|
|
expect(explicit.json).toMatchObject({
|
|
code: "invalid_request",
|
|
details: {
|
|
issues: [
|
|
expect.objectContaining({ path: ["path"], reason: "invalid_format" }),
|
|
],
|
|
},
|
|
});
|
|
},
|
|
);
|