diff options
author | 2023-08-22 09:22:37 +0800 | |
---|---|---|
committer | 2023-08-21 18:22:37 -0700 | |
commit | a61953bbfdfd51cbba67d696b0e77793141c34fc (patch) | |
tree | c75d57de75ca98130348e18fa47f5524e896b2f1 /test/bundler/cli.test.ts | |
parent | f629365cb7a899229c70c6bed14a41fa62ea87f1 (diff) | |
download | bun-a61953bbfdfd51cbba67d696b0e77793141c34fc.tar.gz bun-a61953bbfdfd51cbba67d696b0e77793141c34fc.tar.zst bun-a61953bbfdfd51cbba67d696b0e77793141c34fc.zip |
Fix(bundler): allow generating exe file in nested path. (#4226)
* Fix(bundler): allow generating binary file in nested path.
Close: #4195
* Add read flag for fd.
* refactor
Diffstat (limited to '')
-rw-r--r-- | test/bundler/cli.test.ts | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/test/bundler/cli.test.ts b/test/bundler/cli.test.ts index e2f99a9ed..3df2ab75e 100644 --- a/test/bundler/cli.test.ts +++ b/test/bundler/cli.test.ts @@ -1,6 +1,8 @@ import { bunEnv, bunExe } from "harness"; -import path from "path"; import { describe, expect, test } from "bun:test"; +import fs from "node:fs"; +import { tmpdir } from "node:os"; +import path from "node:path"; describe("bun build", () => { test("warnings dont return exit code 1", () => { @@ -13,4 +15,41 @@ describe("bun build", () => { 'warn: "key" prop before a {...spread} is deprecated in JSX. Falling back to classic runtime.', ); }); + + test("generating a standalone binary in nested path, issue #4195", () => { + function testCompile(outfile: string) { + const { exitCode } = Bun.spawnSync({ + cmd: [ + bunExe(), + "build", + path.join(import.meta.dir, "./fixtures/trivial/index.js"), + "--compile", + "--outfile", + outfile, + ], + env: bunEnv, + }); + expect(exitCode).toBe(0); + } + function testExec(outfile: string) { + const { exitCode } = Bun.spawnSync({ + cmd: [outfile], + }); + expect(exitCode).toBe(0); + } + { + const baseDir = `${tmpdir()}/bun-build-outfile-${Date.now()}`; + const outfile = path.join(baseDir, "index.exe"); + testCompile(outfile); + testExec(outfile); + fs.rmSync(baseDir, { recursive: true, force: true }); + } + { + const baseDir = `${tmpdir()}/bun-build-outfile2-${Date.now()}`; + const outfile = path.join(baseDir, "b/u/n", "index.exe"); + testCompile(outfile); + testExec(outfile); + fs.rmSync(baseDir, { recursive: true, force: true }); + } + }); }); |