aboutsummaryrefslogtreecommitdiff
path: root/test/bundler/cli.test.ts
diff options
context:
space:
mode:
authorGravatar Ai Hoshino <ambiguous404@gmail.com> 2023-08-22 09:22:37 +0800
committerGravatar GitHub <noreply@github.com> 2023-08-21 18:22:37 -0700
commita61953bbfdfd51cbba67d696b0e77793141c34fc (patch)
treec75d57de75ca98130348e18fa47f5524e896b2f1 /test/bundler/cli.test.ts
parentf629365cb7a899229c70c6bed14a41fa62ea87f1 (diff)
downloadbun-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.ts41
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 });
+ }
+ });
});