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