Files
oh-my-pi/packages/coding-agent/test/non-interactive-env.test.ts
T
roboomp 6ad2b0cd2f fix(tool): preserved windows utf-8 env groups
Skipped UTF-8 defaults for an entire Windows locale or Python encoding group when inherited or per-command env already defines one variable in that group.

Fixes #2701
2026-06-15 21:27:46 +00:00

41 lines
1.5 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("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();
});
});