aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js
diff options
context:
space:
mode:
authorGravatar Derrick Farris <mr.dcfarris@gmail.com> 2022-11-09 20:10:29 -0600
committerGravatar GitHub <noreply@github.com> 2022-11-09 18:10:29 -0800
commit7f5022db0ca839262a862f8e2c8012145c4f90f5 (patch)
tree21a63b36a0bfca79830a3a4891af7a38de85cb13 /test/bun.js
parent9ea025c5430d2ed227d61b5f92cd3d6f46d209bd (diff)
downloadbun-7f5022db0ca839262a862f8e2c8012145c4f90f5.tar.gz
bun-7f5022db0ca839262a862f8e2c8012145c4f90f5.tar.zst
bun-7f5022db0ca839262a862f8e2c8012145c4f90f5.zip
fix(child_process): fix execFileSync options.input (#1479)
* fix(child_process): fix execFileSync options.input * fix(child_process): debug err, check for Uint8Array too * fix(child_process): fix ArrayBufferIsView call * test(child_process): fix missing toString() call on test result * refactor(child_process): change options.input to input to getter calls
Diffstat (limited to 'test/bun.js')
-rw-r--r--test/bun.js/child_process.test.ts8
-rw-r--r--test/bun.js/spawned-child.js12
2 files changed, 19 insertions, 1 deletions
diff --git a/test/bun.js/child_process.test.ts b/test/bun.js/child_process.test.ts
index fecc5b961..f39629169 100644
--- a/test/bun.js/child_process.test.ts
+++ b/test/bun.js/child_process.test.ts
@@ -259,6 +259,14 @@ describe("execFileSync()", () => {
const result = execFileSync("bun", ["-v"], { encoding: "utf8" });
expect(SEMVER_REGEX.test(result.trim())).toBe(true);
});
+
+ it("should allow us to pass input to the command", () => {
+ const result = execFileSync("node", ["spawned-child.js", "STDIN"], {
+ input: "hello world!",
+ encoding: "utf8",
+ });
+ expect(result.trim()).toBe("hello world!");
+ });
});
describe("execSync()", () => {
diff --git a/test/bun.js/spawned-child.js b/test/bun.js/spawned-child.js
index 757aacd5c..c70aeab16 100644
--- a/test/bun.js/spawned-child.js
+++ b/test/bun.js/spawned-child.js
@@ -1 +1,11 @@
-setTimeout(() => console.log("hello"), 150);
+if (process.argv[2] === "STDIN") {
+ let result = "";
+ process.stdin.on("data", (data) => {
+ result += data;
+ });
+ process.stdin.on("close", () => {
+ console.log(result);
+ });
+} else {
+ setTimeout(() => console.log("hello"), 150);
+}