Files
bun.sh/test/js/bun/spawn/spawn-path.test.ts
Jarred Sumner 2e02d9de28 Use ReadableStream.prototype.* in tests instead of new Response(...).* (#20937)
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Alistair Smith <hi@alistair.sh>
Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
2025-07-14 00:47:53 -07:00

27 lines
710 B
TypeScript

import { expect, test } from "bun:test";
import { chmodSync } from "fs";
import { bunEnv, isWindows, tempDirWithFiles } from "harness";
import path from "path";
test.skipIf(isWindows)("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 proc.stdout.text();
expect(output.trim()).toBe("hello from script");
const status = await proc.exited;
expect(status).toBe(0);
});