From b2961409b71106b2c2fb257300fb8d43e3ddb7fa Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 14:04:17 +0900 Subject: [PATCH] test(shell-env): add csh/tcsh detection and buildEnvPrefix coverage Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- src/shared/shell-env.test.ts | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/shared/shell-env.test.ts b/src/shared/shell-env.test.ts index ef9aa52ea..bdc1146d2 100644 --- a/src/shared/shell-env.test.ts +++ b/src/shared/shell-env.test.ts @@ -120,6 +120,39 @@ describe("shell-env", () => { expect(result).toBe("unix") }) + + test("#given SHELL set to /bin/csh #when detectShellType is called #then returns csh", () => { + delete process.env.PSModulePath + delete process.env.MSYSTEM + process.env.SHELL = "/bin/csh" + Object.defineProperty(process, "platform", { value: "linux" }) + + const result = detectShellType() + + expect(result).toBe("csh") + }) + + test("#given SHELL set to /bin/tcsh #when detectShellType is called #then returns csh", () => { + delete process.env.PSModulePath + delete process.env.MSYSTEM + process.env.SHELL = "/bin/tcsh" + Object.defineProperty(process, "platform", { value: "linux" }) + + const result = detectShellType() + + expect(result).toBe("csh") + }) + + test("#given SHELL set to /usr/local/bin/tcsh #when detectShellType is called #then returns csh", () => { + delete process.env.PSModulePath + delete process.env.MSYSTEM + process.env.SHELL = "/usr/local/bin/tcsh" + Object.defineProperty(process, "platform", { value: "darwin" }) + + const result = detectShellType() + + expect(result).toBe("csh") + }) }) describe("shellEscape", () => { @@ -311,5 +344,27 @@ describe("shell-env", () => { expect(result).toBe("") }) }) + + describe("csh", () => { + test("#given single environment variable #when buildEnvPrefix is called with csh #then builds setenv command", () => { + const result = buildEnvPrefix({ VAR: "value" }, "csh") + expect(result).toBe("setenv VAR value;") + }) + + test("#given multiple environment variables #when buildEnvPrefix is called with csh #then builds separate setenv commands", () => { + const result = buildEnvPrefix({ VAR1: "val1", VAR2: "val2" }, "csh") + expect(result).toBe("setenv VAR1 val1; setenv VAR2 val2;") + }) + + test("#given env var with spaces #when buildEnvPrefix is called with csh #then escapes value with single quotes", () => { + const result = buildEnvPrefix({ MSG: "has spaces" }, "csh") + expect(result).toBe("setenv MSG 'has spaces';") + }) + + test("#given empty env object #when buildEnvPrefix is called with csh #then returns empty string", () => { + const result = buildEnvPrefix({}, "csh") + expect(result).toBe("") + }) + }) }) })