diff options
Diffstat (limited to 'tests/specs')
6 files changed, 75 insertions, 0 deletions
diff --git a/tests/specs/node/child_process_extra_pipes/__test__.jsonc b/tests/specs/node/child_process_extra_pipes/__test__.jsonc new file mode 100644 index 000000000..f8073f3df --- /dev/null +++ b/tests/specs/node/child_process_extra_pipes/__test__.jsonc @@ -0,0 +1,17 @@ +{ + "tempDir": true, + "steps": [ + { + "if": "unix", + "cwd": "./test-pipe", + "commandName": "cargo", + "args": "build", + "output": "[WILDCARD]" + }, + { + "if": "unix", + "args": "run -A main.ts", + "output": "main.out" + } + ] +} diff --git a/tests/specs/node/child_process_extra_pipes/main.out b/tests/specs/node/child_process_extra_pipes/main.out new file mode 100644 index 000000000..694126b92 --- /dev/null +++ b/tests/specs/node/child_process_extra_pipes/main.out @@ -0,0 +1,5 @@ +data: hello world +[UNORDERED_START] +child closed +pipe closed +[UNORDERED_END] diff --git a/tests/specs/node/child_process_extra_pipes/main.ts b/tests/specs/node/child_process_extra_pipes/main.ts new file mode 100644 index 000000000..a3683fe9e --- /dev/null +++ b/tests/specs/node/child_process_extra_pipes/main.ts @@ -0,0 +1,26 @@ +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", [], { + stdio: ["inherit", "inherit", "inherit", "ignore", "pipe"], +}); + +const extra = child.stdio[4]; + +const p = Promise.withResolvers(); + +child.on("close", () => { + console.log("child closed"); + p.resolve(); +}); + +extra.on("data", (d) => { + console.log("data:", d.toString().trim()); +}); + +extra.on("close", () => { + console.log("pipe closed"); +}); + +await p.promise; diff --git a/tests/specs/node/child_process_extra_pipes/test-pipe/Cargo.lock b/tests/specs/node/child_process_extra_pipes/test-pipe/Cargo.lock new file mode 100644 index 000000000..51bfabdad --- /dev/null +++ b/tests/specs/node/child_process_extra_pipes/test-pipe/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "test-pipe" +version = "0.1.0" diff --git a/tests/specs/node/child_process_extra_pipes/test-pipe/Cargo.toml b/tests/specs/node/child_process_extra_pipes/test-pipe/Cargo.toml new file mode 100644 index 000000000..26c552299 --- /dev/null +++ b/tests/specs/node/child_process_extra_pipes/test-pipe/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "test-pipe" +version = "0.1.0" +edition = "2021" + +[dependencies] + +[workspace] diff --git a/tests/specs/node/child_process_extra_pipes/test-pipe/src/main.rs b/tests/specs/node/child_process_extra_pipes/test-pipe/src/main.rs new file mode 100644 index 000000000..192f82731 --- /dev/null +++ b/tests/specs/node/child_process_extra_pipes/test-pipe/src/main.rs @@ -0,0 +1,12 @@ +use std::io::prelude::*; +use std::os::fd::FromRawFd; +use std::os::unix::net::UnixStream; + +fn main() { + #[cfg(unix)] + { + let mut stream = unsafe { UnixStream::from_raw_fd(4) }; + + stream.write_all(b"hello world\n").unwrap(); + } +} |