summaryrefslogtreecommitdiff
path: root/tests/specs/node/child_process_extra_pipes/main.ts
diff options
context:
space:
mode:
authorhaturau <135221985+haturatu@users.noreply.github.com>2024-11-20 01:20:47 +0900
committerGitHub <noreply@github.com>2024-11-20 01:20:47 +0900
commit85719a67e59c7aa45bead26e4942d7df8b1b42d4 (patch)
treeface0aecaac53e93ce2f23b53c48859bcf1a36ec /tests/specs/node/child_process_extra_pipes/main.ts
parent67697bc2e4a62a9670699fd18ad0dd8efc5bd955 (diff)
parent186b52731c6bb326c4d32905c5e732d082e83465 (diff)
Merge branch 'denoland:main' into main
Diffstat (limited to 'tests/specs/node/child_process_extra_pipes/main.ts')
-rw-r--r--tests/specs/node/child_process_extra_pipes/main.ts20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/specs/node/child_process_extra_pipes/main.ts b/tests/specs/node/child_process_extra_pipes/main.ts
index a3683fe9e..2837cdc53 100644
--- a/tests/specs/node/child_process_extra_pipes/main.ts
+++ b/tests/specs/node/child_process_extra_pipes/main.ts
@@ -1,5 +1,4 @@
import child_process from "node:child_process";
-import { Buffer } from "node:buffer";
import console from "node:console";
const child = child_process.spawn("./test-pipe/target/debug/test-pipe", [], {
@@ -8,19 +7,32 @@ const child = child_process.spawn("./test-pipe/target/debug/test-pipe", [], {
const extra = child.stdio[4];
-const p = Promise.withResolvers();
+if (!extra) {
+ throw new Error("no extra pipe");
+}
+
+const p = Promise.withResolvers<void>();
+
+let got = "";
child.on("close", () => {
console.log("child closed");
- p.resolve();
+ console.log("got:", got);
+ if (got === "hello world") {
+ p.resolve();
+ } else {
+ p.reject(new Error(`wanted "hello world", got "${got}"`));
+ }
});
extra.on("data", (d) => {
- console.log("data:", d.toString().trim());
+ got += d.toString();
});
extra.on("close", () => {
console.log("pipe closed");
});
+extra.write("start");
+
await p.promise;