aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/bun.js/child-process-stdio.test.js22
-rw-r--r--test/bun.js/console-iterator.test.js17
-rw-r--r--test/bun.js/ffi.test.fixture.callback.c3
-rw-r--r--test/bun.js/filesink.test.ts1
-rw-r--r--test/bun.js/spawned-child.js22
5 files changed, 18 insertions, 47 deletions
diff --git a/test/bun.js/child-process-stdio.test.js b/test/bun.js/child-process-stdio.test.js
index 75ab0e49f..9969473be 100644
--- a/test/bun.js/child-process-stdio.test.js
+++ b/test/bun.js/child-process-stdio.test.js
@@ -4,21 +4,11 @@ import { spawn, execSync } from "node:child_process";
const CHILD_PROCESS_FILE = import.meta.dir + "/spawned-child.js";
const OUT_FILE = import.meta.dir + "/stdio-test-out.txt";
-// describe("process.stdout", () => {
-// // it("should allow us to write to it", () => {
-// // process.stdout.write("Bun is cool\n");
-// // });
-// // it("should allow us to use a file as stdout", () => {
-// // const output = "Bun is cool\n";
-// // execSync(`rm -f ${OUT_FILE}`);
-// // const result = execSync(`bun ${CHILD_PROCESS_FILE} STDOUT > ${OUT_FILE}`, {
-// // encoding: "utf8",
-// // stdin,
-// // });
-// // expect(result).toBe(output);
-// // expect(readSync(OUT_FILE)).toBe(output);
-// // });
-// });
+describe("process.stdout", () => {
+ it("should allow us to write to it", () => {
+ process.stdout.write("Bun is cool\n");
+ });
+});
describe("process.stdin", () => {
it("should allow us to read from stdin in readable mode", (done) => {
@@ -75,6 +65,6 @@ describe("process.stdin", () => {
}/readFileSync.txt`,
{ encoding: "utf8" },
);
- expect(result.trim()).toEqual("File read successfully");
+ expect(result.trim()).toEqual("data: File read successfully");
});
});
diff --git a/test/bun.js/console-iterator.test.js b/test/bun.js/console-iterator.test.js
index c211fe8e6..533f084e1 100644
--- a/test/bun.js/console-iterator.test.js
+++ b/test/bun.js/console-iterator.test.js
@@ -10,7 +10,7 @@ describe("should work for static input", () => {
"hello world\n\n\n",
"Hello\nWorld\n",
"1",
- "❤️ Red Heart ✨ Sparkles 🔥 Fire\n❤️ Red Heart ✨ Sparkles\n❤️ Red Heart\n❤️\n\nnormal",
+ "💕 Red Heart ✨ Sparkles 🔥 Fire\n💕 Red Heart ✨ Sparkles\n💕 Red Heart\n💕\n\nnormal",
];
for (let input of inputs) {
@@ -35,12 +35,12 @@ describe("should work for streaming input", () => {
"hello world\n\n\n",
"Hello\nWorld\n",
"1",
- "❤️ Red Heart ✨ Sparkles 🔥 Fire\n❤️ Red Heart ✨ Sparkles\n❤️ Red Heart\n❤️\n\nnormal",
+ "💕 Red Heart ✨ Sparkles 🔥 Fire\n 💕 Red Heart ✨ Sparkles\n 💕 Red Heart\n 💕 \n\nnormal",
];
for (let input of inputs) {
it(input.replaceAll("\n", "\\n"), async () => {
- const { stdout, stdin } = spawn({
+ const proc = spawn({
cmd: [bunExe(), import.meta.dir + "/" + "console-iterator-run.js"],
stdin: "pipe",
stdout: "pipe",
@@ -48,17 +48,18 @@ describe("should work for streaming input", () => {
BUN_DEBUG_QUIET_LOGS: "1",
},
});
- stdin.write(input.slice(0, 4));
- await new Promise((resolve) => setTimeout(resolve, 1));
- stdin.write(input.slice(4, 5));
- await new Promise((resolve) => setTimeout(resolve, 1));
- stdin.write(input.slice(5));
+ const { stdout, stdin } = proc;
+ stdin.write(input.slice(0, (input.length / 2) | 0));
+ stdin.flush();
await new Promise((resolve) => setTimeout(resolve, 1));
+ stdin.write(input.slice((input.length / 2) | 0));
+ stdin.flush();
stdin.end();
expect(await new Response(stdout).text()).toBe(
input.replaceAll("\n", ""),
);
+ proc.kill(0);
});
}
});
diff --git a/test/bun.js/ffi.test.fixture.callback.c b/test/bun.js/ffi.test.fixture.callback.c
index ec83dee80..9c3c088ce 100644
--- a/test/bun.js/ffi.test.fixture.callback.c
+++ b/test/bun.js/ffi.test.fixture.callback.c
@@ -285,6 +285,9 @@ ZIG_REPR_TYPE JSFunctionCall(void* jsGlobalObject, void* callFrame);
bool my_callback_function(void* arg0);
bool my_callback_function(void* arg0) {
+#ifdef INJECT_BEFORE
+INJECT_BEFORE;
+#endif
ZIG_REPR_TYPE arguments[1];
arguments[0] = PTR_TO_JSVALUE(arg0).asZigRepr;
return (bool)JSVALUE_TO_BOOL(_FFI_Callback_call((void*)0x0UL, 1, arguments));
diff --git a/test/bun.js/filesink.test.ts b/test/bun.js/filesink.test.ts
index a04144d0b..2e6174ba7 100644
--- a/test/bun.js/filesink.test.ts
+++ b/test/bun.js/filesink.test.ts
@@ -106,7 +106,6 @@ describe("FileSink", () => {
for (let i = 0; i < input.length; i++) {
sink.write(input[i]);
}
- console.log("close", input[0].length);
await sink.end();
if (!isPipe) {
diff --git a/test/bun.js/spawned-child.js b/test/bun.js/spawned-child.js
index 276930503..a90dfade2 100644
--- a/test/bun.js/spawned-child.js
+++ b/test/bun.js/spawned-child.js
@@ -1,25 +1,3 @@
-if (globalThis.Bun) {
- const nodeStream = require("node:stream");
- const nodeFs = require("node:fs");
-
- // TODO: Remove this polyfill once we have integrated polyfill into runtime init
- const {
- stdin: _stdinInit,
- stdout: _stdoutInit,
- stderr: _stderrInit,
- } = require("../../src/bun.js/process-stdio-polyfill.js");
-
- function _require(mod) {
- if (mod === "node:stream") return nodeStream;
- if (mod === "node:fs") return nodeFs;
- throw new Error(`Unknown module: ${mod}`);
- }
-
- process.stdin = _stdinInit({ require: _require });
- process.stdout = _stdoutInit({ require: _require });
- process.stderr = _stderrInit({ require: _require });
-}
-
const TARGET = process.argv[2];
const MODE = process.argv[3];