aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/process-args.test.js
diff options
context:
space:
mode:
authorGravatar Dylan Conway <35280289+dylan-conway@users.noreply.github.com> 2022-10-18 20:11:17 -0700
committerGravatar GitHub <noreply@github.com> 2022-10-18 20:11:17 -0700
commit1835e4b9f93ba9324bca2bed588f42c93a2772de (patch)
tree70707afdc82e736a3b7eb3818e22019104b81264 /test/bun.js/process-args.test.js
parent8ca49f906acdd4f8bdb9f42c6b5c47b098308dcd (diff)
downloadbun-1835e4b9f93ba9324bca2bed588f42c93a2772de.tar.gz
bun-1835e4b9f93ba9324bca2bed588f42c93a2772de.tar.zst
bun-1835e4b9f93ba9324bca2bed588f42c93a2772de.zip
get args fix (#1346)
* fix args.len < capacity check * tests for args * file name change * switch to stdout.writer, use JSON for parsing * bun-debug or bun * missing arg
Diffstat (limited to 'test/bun.js/process-args.test.js')
-rw-r--r--test/bun.js/process-args.test.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/bun.js/process-args.test.js b/test/bun.js/process-args.test.js
new file mode 100644
index 000000000..6bdfbf9e0
--- /dev/null
+++ b/test/bun.js/process-args.test.js
@@ -0,0 +1,33 @@
+
+import { spawn } from "bun";
+import { test, expect } from "bun:test";
+
+test("args exclude run", async () => {
+ const arg0 = process.argv[0];
+ const arg1 = import.meta.dir + '/print-process-args.js';
+
+ const exe = process.versions.bun.includes("debug") ? "bun-debug" : "bun";
+
+ const { stdout: s1 } = spawn([exe, "print-process-args.js"], { cwd: import.meta.dir });
+ const t1 = JSON.parse(await new Response(s1).text());
+ expect(t1[0]).toBe(arg0);
+ expect(t1[1]).toBe(arg1);
+
+ const { stdout: s2 } = spawn([exe, "print-process-args.js", "arg1"], { cwd: import.meta.dir });
+ const t2 = JSON.parse(await new Response(s2).text());
+ expect(t2[0]).toBe(arg0);
+ expect(t2[1]).toBe(arg1);
+ expect(t2[2]).toBe("arg1");
+
+ const { stdout: s3 } = spawn([exe, "run", "print-process-args.js"], { cwd: import.meta.dir });
+ const t3 = JSON.parse(await new Response(s3).text());
+ expect(t3[0]).toBe(arg0);
+ expect(t3[1]).toBe(arg1);
+
+ const { stdout: s4 } = spawn([exe, "run", "print-process-args.js", "arg1", "arg2"], { cwd: import.meta.dir });
+ const t4 = JSON.parse(await new Response(s4).text());
+ expect(t4[0]).toBe(arg0);
+ expect(t4[1]).toBe(arg1);
+ expect(t4[2]).toBe("arg1");
+ expect(t4[3]).toBe("arg2");
+}); \ No newline at end of file