diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-03-28 19:44:42 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-28 19:44:42 +0530 |
commit | bca0fe1cde3d30ce31c158862cc6764babf71a14 (patch) | |
tree | c494cabd61a859a31307f43bc09721ff70f17031 /tests | |
parent | de0b230078daebbbec82ea5d7aabb9f0a429125f (diff) |
fix(ext/node): support stdin: "inherit" in node:child_process (#23110)
Fixes https://github.com/denoland/deno/issues/23051
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit_node/child_process_test.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/unit_node/child_process_test.ts b/tests/unit_node/child_process_test.ts index 6a1d1dbc5..23de928db 100644 --- a/tests/unit_node/child_process_test.ts +++ b/tests/unit_node/child_process_test.ts @@ -823,3 +823,35 @@ Deno.test(function spawnCommandNullStdioArray() { assertEquals(ret.status, 0); }); + +Deno.test( + function stdinInherit() { + const script = ` + function timeoutPromise(promise, timeout) { + return new Promise((resolve, reject) => { + const timeoutId = setTimeout(() => { + Deno.exit(69); + }, timeout); + promise.then((value) => { + clearTimeout(timeoutId); + resolve(value); + }, (reason) => { + clearTimeout(timeoutId); + reject(reason); + }); + }); + } + + await timeoutPromise(Deno.stdin.read(new Uint8Array(1)), 100) + `; + + const output = spawnSync(Deno.execPath(), ["eval", script], { + stdio: "inherit", + }); + + // We want to timeout to occur because the stdin isn't 'null' + assertEquals(output.status, 69); + assertEquals(output.stdout, null); + assertEquals(output.stderr, null); + }, +); |