From bd495e48354961bda6903c5be2e869459fc6da80 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Thu, 13 Aug 2026 22:15:29 +0000 Subject: [PATCH 1/2] test(install): give each long-label bun patch test its own install cache The "packages whose label is longer than 1024 bytes" tests run concurrently and two of them install `bar` from the identical spec. They relied on the cache dir createTestDir writes to bunfig.toml to keep the projects apart, but CI exports BUN_INSTALL_CACHE_DIR, which takes precedence, so both installs published the same cache entry into one shared cache at the same time. On Windows the install that publishes second evicts the first one's entry while it is still being read, and that install exits 1, which failed the test on both Windows lanes. Pin BUN_INSTALL_CACHE_DIR per project, as the other install tests do, and attach the install's stderr to the exit code assertion so a failing install says why. --- test/cli/install/bun-patch.test.ts | 45 +++++++++++++++++------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/test/cli/install/bun-patch.test.ts b/test/cli/install/bun-patch.test.ts index ec6b0b5a061c..129280336d28 100644 --- a/test/cli/install/bun-patch.test.ts +++ b/test/cli/install/bun-patch.test.ts @@ -85,7 +85,12 @@ describe("packages whose label is longer than 1024 bytes", () => { // on every platform while the recorded spec stays long. const longSpec = (tarball: string) => `./${Buffer.alloc(1050, "x/../").toString()}${tarball}`; - async function createProject(tarball: string, packageJson: Record) { + type Project = { packageDir: string; env: Record }; + + // CI exports BUN_INSTALL_CACHE_DIR, which overrides the cache createTestDir writes to bunfig.toml. + // Two of these concurrent tests install `bar` from the identical spec, and two installs publishing + // the same entry into one shared cache at the same time fail on Windows, so pin a cache per project. + async function createProject(tarball: string, packageJson: Record): Promise { const { packageDir } = await registry.createTestDir({ bunfigOpts: { linker: "hoisted" }, files: { @@ -93,14 +98,14 @@ describe("packages whose label is longer than 1024 bytes", () => { [tarball]: readFileSync(join(import.meta.dir, tarball)), }, }); - return packageDir; + return { packageDir, env: { ...bunEnv, BUN_INSTALL_CACHE_DIR: join(packageDir, ".bun-cache") } }; } - async function runBun(cwd: string, ...args: string[]) { + async function runBun({ packageDir, env }: Project, ...args: string[]) { await using proc = Bun.spawn({ cmd: [bunExe(), ...args], - cwd, - env: bunEnv, + cwd: packageDir, + env, stdout: "pipe", stderr: "pipe", }); @@ -108,18 +113,18 @@ describe("packages whose label is longer than 1024 bytes", () => { return { stdout, stderr, exitCode }; } - async function install(cwd: string) { - const { stderr, exitCode } = await runBun(cwd, "install"); + async function install(project: Project) { + const { stderr, exitCode } = await runBun(project, "install"); expect(stderr).not.toContain("error:"); - expect(exitCode).toBe(0); + expect(exitCode, stderr).toBe(0); } test.concurrent("bun patch @