diff options
author | 2023-01-16 16:28:02 -0800 | |
---|---|---|
committer | 2023-01-16 16:28:02 -0800 | |
commit | 7dd28bbdd99b31cc88abe4b309ed52aff64be9c2 (patch) | |
tree | ae3b2c0ae4d790995801a59de78fdb3fd5c896af /test/bun.js | |
parent | d54e23ca33cc95199a58d958abf990d9a6e1eb26 (diff) | |
download | bun-7dd28bbdd99b31cc88abe4b309ed52aff64be9c2.tar.gz bun-7dd28bbdd99b31cc88abe4b309ed52aff64be9c2.tar.zst bun-7dd28bbdd99b31cc88abe4b309ed52aff64be9c2.zip |
Fix `which` returning directories sometimes
Diffstat (limited to 'test/bun.js')
-rw-r--r-- | test/bun.js/which.test.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/bun.js/which.test.ts b/test/bun.js/which.test.ts index 150bfa767..e142e398c 100644 --- a/test/bun.js/which.test.ts +++ b/test/bun.js/which.test.ts @@ -1,6 +1,7 @@ import { test, expect } from "bun:test"; import { which } from "bun"; +import { chmodSync, mkdirSync, unlinkSync } from "node:fs"; test("which", () => { writeFixture("/tmp/myscript.sh"); @@ -8,6 +9,14 @@ test("which", () => { // Our cwd is not /tmp expect(which("myscript.sh")).toBe(null); + try { + mkdirSync("myscript.sh"); + chmodSync("myscript.sh", "755"); + } catch (e) {} + + // directories should not be returned + expect(which("myscript.sh")).toBe(null); + // "bun" is in our PATH expect(which("bun")?.length > 0).toBe(true); @@ -37,6 +46,10 @@ test("which", () => { cwd: "/tmp", }), ).toBe("/tmp/myscript.sh"); + + try { + unlinkSync("myscript.sh"); + } catch (e) {} }); function writeFixture(path) { |