Skip to content

Commit 43d2eb8

Browse files
committed
test(bash): fix env parameter tests for Windows compatibility
Use Bun's process.env instead of shell-specific echo syntax for cross-platform support - Replace Unix $VAR syntax with bun -e "console.log(process.env.VAR)" - Use existing test helpers (bin, evalarg) for proper quoting - Tests now pass on Windows regardless of shell type
1 parent a3d7f5c commit 43d2eb8

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

packages/opencode/test/tool/bash.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,14 +1099,15 @@ describe("tool.bash truncation", () => {
10991099
})
11001100

11011101
describe("tool.bash env", () => {
1102-
test("sets environment variables", async () => {
1102+
each("sets environment variables", async () => {
11031103
await Instance.provide({
11041104
directory: projectRoot,
11051105
fn: async () => {
11061106
const bash = await BashTool.init()
1107+
const code = "console.log(process.env.TEST_VAR)"
11071108
const result = await bash.execute(
11081109
{
1109-
command: "echo $TEST_VAR",
1110+
command: `${bin} -e ${evalarg(code)}`,
11101111
description: "Echo environment variable",
11111112
env: { TEST_VAR: "hello_world" },
11121113
},
@@ -1118,21 +1119,23 @@ describe("tool.bash env", () => {
11181119
})
11191120
})
11201121

1121-
test("sets multiple environment variables", async () => {
1122+
each("sets multiple environment variables", async () => {
11221123
await Instance.provide({
11231124
directory: projectRoot,
11241125
fn: async () => {
11251126
const bash = await BashTool.init()
1127+
const code = "console.log(process.env.VAR1, process.env.VAR2)"
11261128
const result = await bash.execute(
11271129
{
1128-
command: "echo $VAR1 $VAR2",
1130+
command: `${bin} -e ${evalarg(code)}`,
11291131
description: "Echo multiple environment variables",
11301132
env: { VAR1: "foo", VAR2: "bar" },
11311133
},
11321134
ctx,
11331135
)
11341136
expect(result.metadata.exit).toBe(0)
1135-
expect(result.output).toContain("foo bar")
1137+
expect(result.output).toContain("foo")
1138+
expect(result.output).toContain("bar")
11361139
},
11371140
})
11381141
})

0 commit comments

Comments
 (0)