diff options
author | 2023-02-12 07:35:33 +0200 | |
---|---|---|
committer | 2023-02-11 21:35:33 -0800 | |
commit | 8b4e58f3d225e30d186fc2d208dea477a2f9b5a5 (patch) | |
tree | d7058ad0502e5af60ef0ccc78f56f33b03ac7d6c /test/bun.js | |
parent | 30e82c5df42fab71a238cd9b7d268cbb6510bd7a (diff) | |
download | bun-8b4e58f3d225e30d186fc2d208dea477a2f9b5a5.tar.gz bun-8b4e58f3d225e30d186fc2d208dea477a2f9b5a5.tar.zst bun-8b4e58f3d225e30d186fc2d208dea477a2f9b5a5.zip |
fix string corruption in FS entry cache (#2055)
Diffstat (limited to 'test/bun.js')
-rw-r--r-- | test/bun.js/install/bunx.test.ts | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/test/bun.js/install/bunx.test.ts b/test/bun.js/install/bunx.test.ts index 08ec3fc50..76cd944a1 100644 --- a/test/bun.js/install/bunx.test.ts +++ b/test/bun.js/install/bunx.test.ts @@ -53,11 +53,11 @@ it("should install and run specified version", async () => { expect(await exited).toBe(0); }); -it("should download dependencies to run local file", async () => { +it("should download dependency to run local file", async () => { await writeFile( join(x_dir, "test.js"), ` -import { minify } from "uglify-js"; +const { minify } = require("uglify-js@3.17.4"); console.log(minify("print(6 * 7)").code); `, @@ -82,3 +82,42 @@ console.log(minify("print(6 * 7)").code); expect(await exited).toBe(0); expect(await readdirSorted(x_dir)).toEqual([".cache", "test.js"]); }); + +it("should download dependencies to run local file", async () => { + await writeFile( + join(x_dir, "test.js"), + ` +import { file } from "bun"; +import decompress from "decompress@4.2.1"; + +const buffer = await file("${join(import.meta.dir, "baz-0.0.3.tgz")}").arrayBuffer(); +for (const entry of await decompress(Buffer.from(buffer))) { + console.log(\`\${entry.type}: \${entry.path}\`); +} +`, + ); + const { stdout, stderr, exited } = spawn({ + cmd: [bunExe(), "test.js"], + cwd: x_dir, + stdout: null, + stdin: "pipe", + stderr: "pipe", + env: { + ...env, + BUN_INSTALL_CACHE_DIR: join(x_dir, ".cache"), + }, + }); + expect(stderr).toBeDefined(); + const err = await new Response(stderr).text(); + expect(err).toBe(""); + expect(stdout).toBeDefined(); + const out = await new Response(stdout).text(); + expect(out.split(/\r?\n/)).toEqual([ + "directory: package/", + "file: package/index.js", + "file: package/package.json", + "", + ]); + expect(await exited).toBe(0); + expect(await readdirSorted(x_dir)).toEqual([".cache", "test.js"]); +}); |