Files
llmx/codex-cli/tests/invalid-command-handling.test.ts
Luci a9ecb2efce chore: upgrade prettier to v3 (#644)
## Description

This PR addresses the following improvements:

**Unify Prettier Version**: Currently, the Prettier version used in
`/package.json` and `/codex-cli/package.json` are different. In this PR,
we're updating both to use Prettier v3.

- Prettier v3 introduces improved support for JavaScript and TypeScript.
(e.g. the formatting scenario shown in the image below. This is more
aligned with the TypeScript indentation standard).

<img width="1126" alt="image"
src="https://github.com/user-attachments/assets/6e237eb8-4553-4574-b336-ed9561c55370"
/>

**Add Prettier Auto-Formatting in lint-staged**: We've added a step to
automatically run prettier --write on JavaScript and TypeScript files as
part of the lint-staged process, before the ESLint checks.

- This will help ensure that all committed code is properly formatted
according to the project's Prettier configuration.
2025-04-25 07:21:50 -07:00

69 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, it, expect, vi } from "vitest";
// ---------------------------------------------------------------------------
// Lowlevel rawExec test ------------------------------------------------------
// ---------------------------------------------------------------------------
import { exec as rawExec } from "../src/utils/agent/sandbox/raw-exec.js";
describe("rawExec invalid command handling", () => {
it("resolves with nonzero exit code when executable is missing", async () => {
const cmd = ["definitely-not-a-command-1234567890"];
const result = await rawExec(cmd, {}, []);
expect(result.exitCode).not.toBe(0);
expect(result.stderr.length).toBeGreaterThan(0);
});
});
// ---------------------------------------------------------------------------
// Higherlevel handleExecCommand test ----------------------------------------
// ---------------------------------------------------------------------------
// Mock approvals and logging helpers so the test focuses on execution flow.
vi.mock("../src/approvals.js", () => {
return {
__esModule: true,
canAutoApprove: () =>
({ type: "auto-approve", runInSandbox: false }) as any,
isSafeCommand: () => null,
};
});
vi.mock("../src/format-command.js", () => {
return {
__esModule: true,
formatCommandForDisplay: (cmd: Array<string>) => cmd.join(" "),
};
});
vi.mock("../src/utils/agent/log.js", () => ({
__esModule: true,
log: () => {},
isLoggingEnabled: () => false,
}));
import { handleExecCommand } from "../src/utils/agent/handle-exec-command.js";
describe("handleExecCommand invalid executable", () => {
it("returns nonzero exit code for 'git show' as a single argv element", async () => {
const execInput = { cmd: ["git show"] } as any;
const config = { model: "any", instructions: "" } as any;
const policy = { mode: "auto" } as any;
const getConfirmation = async () => ({ review: "yes" }) as any;
const additionalWritableRoots: Array<string> = [];
const { outputText, metadata } = await handleExecCommand(
execInput,
config,
policy,
additionalWritableRoots,
getConfirmation,
);
expect(metadata["exit_code"]).not.toBe(0);
expect(String(outputText).length).toBeGreaterThan(0);
});
});