e4ab780345
Added Windows-only UTF-8 defaults for non-interactive bash child process environments when the inherited env does not already define encoding or locale values. Added regression coverage for missing, inherited, per-command, and non-Windows env behavior. Fixes #2701
36 lines
1.2 KiB
TypeScript
36 lines
1.2 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 and per-command Windows encoding overrides", () => {
|
|
const env = buildNonInteractiveEnv(
|
|
{ PYTHONUTF8: "0", LC_ALL: "en_US.UTF-8" },
|
|
{ pythonioencoding: "cp1252", LANG: "de_DE.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();
|
|
});
|
|
});
|