Path: blob/main/lang/bun/files/patch-test_regression_issue_10132.test.ts
46591 views
-- Fix $.cwd() global state leak from test 10132 into subsequent test files.1-- Test 10132 sets $.cwd() in a test body but never resets it via afterAll.2-- When tests run in the same process (bun test --jobs 1), this leaks the3-- deleted temp dir path as the shell cwd to following test files, causing4-- ENOENT failures in tests 17405 and 17294 that use the bun Shell ($).5--- test/regression/issue/10132.test.ts.orig 2026-04-27 17:36:19 UTC6+++ test/regression/issue/10132.test.ts7@@ -1,5 +1,5 @@ import { $ } from "bun";8import { $ } from "bun";9-import { beforeAll, expect, test } from "bun:test";10+import { afterAll, beforeAll, expect, test } from "bun:test";11import { chmodSync } from "fs";12import { bunExe, isPosix, tempDirWithFiles } from "harness";13import { join } from "path";14@@ -50,6 +50,11 @@ echo My name is bun-hello215}16});1718+const originalCwd = process.cwd();19+afterAll(() => {20+ $.cwd(originalCwd);21+});22+23test("bun run sets cwd for script, matching npm", async () => {24$.cwd(dir);25const currentPwd = (await $`${bunExe()} run get-pwd`.text()).trim();26@@ -80,4 +85,5 @@ test("issue #10132, bun run sets PATH", async () => {27join(dir, "subdir", "one", "two", "three"),28].map(run),29);30+ $.cwd(process.cwd());31});323334