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 <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -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("")
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user