From ed687afcccc341cb0ac6e16bf1ffed9aa5ab617a Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Mon, 1 Dec 2025 20:01:54 +0000 Subject: [PATCH] test: use harness resource-management in outdir/outfile test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace tmpdirSync() with tempDir() and wrap Bun.spawn() with "await using" to ensure proper cleanup of spawned process and temporary directory. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- test/bundler/cli.test.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/bundler/cli.test.ts b/test/bundler/cli.test.ts index 265e8cd3ba..03ca12fb5d 100644 --- a/test/bundler/cli.test.ts +++ b/test/bundler/cli.test.ts @@ -421,18 +421,17 @@ test("log case 2", async () => { }); test("cannot use both --outdir and --outfile", async () => { - const tmpdir = tmpdirSync(); - const inputFile = path.join(tmpdir, "input.js"); + using dir = tempDir("outdir-outfile-test", { + "input.js": 'console.log("Hello, world!");', + }); - writeFileSync(inputFile, 'console.log("Hello, world!");'); - - const { exited, stderr } = Bun.spawn({ - cmd: [bunExe(), "build", "--outdir=" + tmpdir + "/out", "--outfile=" + tmpdir + "/out.js", inputFile], + await using subprocess = Bun.spawn({ + cmd: [bunExe(), "build", "--outdir=" + dir + "/out", "--outfile=" + dir + "/out.js", dir + "/input.js"], env: bunEnv, - cwd: tmpdir, + cwd: String(dir), stderr: "pipe", }); - expect(await stderr.text()).toContain("cannot use both --outdir and --outfile"); - expect(await exited).not.toBe(0); + expect(await subprocess.stderr.text()).toContain("cannot use both --outdir and --outfile"); + expect(await subprocess.exited).not.toBe(0); });