-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e96dded
commit b3d5ff4
Showing
2 changed files
with
66 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { test, expect } from "bun:test"; | ||
import { chmodSync } from "fs"; | ||
import { tempDirWithFiles, bunEnv } from "harness"; | ||
import path from "path"; | ||
test("spawn uses PATH from env if present", async () => { | ||
const tmpDir = await tempDirWithFiles("spawn-path", { | ||
"test-script": `#!/usr/bin/env bash | ||
echo "hello from script"`, | ||
}); | ||
|
||
chmodSync(path.join(tmpDir, "test-script"), 0o777); | ||
|
||
const proc = Bun.spawn(["test-script"], { | ||
env: { | ||
...bunEnv, | ||
PATH: tmpDir + ":" + bunEnv.PATH, | ||
}, | ||
}); | ||
|
||
const output = await new Response(proc.stdout).text(); | ||
expect(output.trim()).toBe("hello from script"); | ||
|
||
const status = await proc.exited; | ||
expect(status).toBe(0); | ||
}); |