diff options
Diffstat (limited to 'test/bun.js/which.test.ts')
-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) { |