Files
oh-my-pi/packages/coding-agent/test/non-interactive-env.test.ts
T
roboomp 159484ca6f fix(commit): created commits before agent teardown
- Ran commit host completion before commit-agent session disposal so mnemopi/autolearn teardown cannot preempt a valid proposal.

- Converted missing commit-agent host outputs and split-plan gaps into thrown errors so omp commit cannot resolve into exit 0 without creating a commit.

- Preserved caller GPG_TTY state instead of forcing a bogus signing TTY in git and non-interactive subprocess environments.

Fixes #4794
2026-07-11 00:58:34 +00:00

60 lines
2.0 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import { buildNonInteractiveEnv } from "@oh-my-pi/pi-coding-agent/exec/non-interactive-env";
describe("buildNonInteractiveEnv", () => {
it("defaults Windows child-process encoding to UTF-8 when inherited env is unset", () => {
const env = buildNonInteractiveEnv(undefined, {}, "win32");
expect(env.PYTHONIOENCODING).toBe("utf-8");
expect(env.PYTHONUTF8).toBe("1");
expect(env.LANG).toBe("C.UTF-8");
expect(env.LC_ALL).toBe("C.UTF-8");
});
it("preserves inherited Windows encoding groups as user-owned", () => {
const env = buildNonInteractiveEnv(undefined, { PYTHONUTF8: "0", LANG: "de_DE.UTF-8" }, "win32");
expect(env.PYTHONIOENCODING).toBeUndefined();
expect(env.PYTHONUTF8).toBeUndefined();
expect(env.LANG).toBeUndefined();
expect(env.LC_ALL).toBeUndefined();
});
it("preserves per-command Windows encoding groups as user-owned", () => {
const env = buildNonInteractiveEnv({ PYTHONUTF8: "0", LC_ALL: "en_US.UTF-8" }, {}, "win32");
expect(env.PYTHONIOENCODING).toBeUndefined();
expect(env.PYTHONUTF8).toBe("0");
expect(env.LANG).toBeUndefined();
expect(env.LC_ALL).toBe("en_US.UTF-8");
});
it("preserves inherited Windows LC category locales as user-owned", () => {
const env = buildNonInteractiveEnv(undefined, { LC_CTYPE: "en_US.UTF-8" }, "win32");
expect(env.LANG).toBeUndefined();
expect(env.LC_ALL).toBeUndefined();
});
it("does not force UTF-8 encoding defaults on non-Windows platforms", () => {
const env = buildNonInteractiveEnv(undefined, {}, "linux");
expect(env.PYTHONIOENCODING).toBeUndefined();
expect(env.PYTHONUTF8).toBeUndefined();
expect(env.LANG).toBeUndefined();
expect(env.LC_ALL).toBeUndefined();
});
it("does not invent a bogus GPG_TTY", () => {
const env = buildNonInteractiveEnv(undefined, {}, "linux");
expect(env).not.toHaveProperty("GPG_TTY");
});
it("preserves per-command GPG_TTY overrides", () => {
const env = buildNonInteractiveEnv({ GPG_TTY: "/dev/pts/7" }, {}, "linux");
expect(env.GPG_TTY).toBe("/dev/pts/7");
});
});