diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2024-04-27 20:25:18 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-27 20:25:18 +0900 |
commit | 8178f758bc249f12fb82fce15a8f63be1b907ddb (patch) | |
tree | df7d923d885962ee7207423504f9df9a2229b1e3 /tests/integration | |
parent | e3d79c1703b7990f8ec6e1383abe0d2a8531fae8 (diff) |
fix(ext/node): support process.stdin.unref() (#22865)
This PR adds private `[REF]()` and `[UNREF]()` methods to Stdin class,
and call them from Node.js polyfill layer (`TTY` class). This enables
`process.stdin.unref()` and `process.stdin.ref()` for the case when
stdin is terminal.
closes #21796
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/run_tests.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index 6419f6ff0..eec10f64f 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -5359,3 +5359,32 @@ fn code_cache_npm_with_require_test() { assert!(!output.stderr().contains("Updating V8 code cache")); } } + +#[test] +fn node_process_stdin_unref_with_pty() { + TestContext::default() + .new_command() + .args_vec(["run", "--quiet", "run/node_process_stdin_unref_with_pty.js"]) + .with_pty(|mut console| { + console.expect("START\r\n"); + console.write_line("foo"); + console.expect("foo\r\n"); + console.write_line("bar"); + console.expect("bar\r\n"); + console.write_line("baz"); + console.expect("baz\r\n"); + }); + + TestContext::default() + .new_command() + .args_vec([ + "run", + "--quiet", + "run/node_process_stdin_unref_with_pty.js", + "--unref", + ]) + .with_pty(|mut console| { + // if process.stdin.unref is called, the program immediately ends by skipping reading from stdin. + console.expect("START\r\nEND\r\n"); + }); +} |