summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/run_tests.rs29
-rw-r--r--tests/testdata/run/node_process_stdin_unref_with_pty.js14
2 files changed, 43 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");
+ });
+}
diff --git a/tests/testdata/run/node_process_stdin_unref_with_pty.js b/tests/testdata/run/node_process_stdin_unref_with_pty.js
new file mode 100644
index 000000000..e86304981
--- /dev/null
+++ b/tests/testdata/run/node_process_stdin_unref_with_pty.js
@@ -0,0 +1,14 @@
+import process from "node:process";
+import util from "node:util";
+
+console.log("START");
+globalThis.addEventListener("unload", () => console.log("END"));
+
+const args = util.parseArgs({ options: { unref: { type: "boolean" } } });
+
+// call stdin.unref if --unref is passed
+if (args.values.unref) {
+ process.stdin.unref();
+}
+
+process.stdin.pipe(process.stdout);