Files
oh-my-pi/packages/coding-agent/test/non-interactive-env.test.ts
T
roboomp 7dda4441e1 fix(tool): respected windows lc locale env
Treat inherited LC_* category locale variables as ownership of the locale group before adding LANG or LC_ALL defaults.

Fixes #2701
2026-06-15 21:38:32 +00:00

48 lines
1.7 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();
});
});