summaryrefslogtreecommitdiff
path: root/test/pseudo-tty/test-set-raw-mode-reset-process-exit.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-05-30 11:18:43 +0200
committerAnna Henningsen <anna@addaleax.net>2018-06-01 10:52:06 +0200
commit7c8eec0648d1d53dd8ade9d69c4dbbbf2d025a8f (patch)
tree94dcd91a5aacebda7192d24781d377f0aba1dd63 /test/pseudo-tty/test-set-raw-mode-reset-process-exit.js
parent48a2568f411cf09999b7e82992d15142ce9a45b0 (diff)
downloadandroid-node-v8-7c8eec0648d1d53dd8ade9d69c4dbbbf2d025a8f.tar.gz
android-node-v8-7c8eec0648d1d53dd8ade9d69c4dbbbf2d025a8f.tar.bz2
android-node-v8-7c8eec0648d1d53dd8ade9d69c4dbbbf2d025a8f.zip
test: check TTY mode reset on exit
Before PR 20592, closing all handles associated with the main event loop would also mean that `uv_tty_reset_mode()` can’t function properly because the corresponding FDs have already been closed. Add regression tests for this condition. Refs: https://github.com/nodejs/node/issues/21020 Refs: https://github.com/nodejs/node/pull/20592 PR-URL: https://github.com/nodejs/node/pull/21027 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/pseudo-tty/test-set-raw-mode-reset-process-exit.js')
-rw-r--r--test/pseudo-tty/test-set-raw-mode-reset-process-exit.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/pseudo-tty/test-set-raw-mode-reset-process-exit.js b/test/pseudo-tty/test-set-raw-mode-reset-process-exit.js
new file mode 100644
index 0000000000..b6857eaebb
--- /dev/null
+++ b/test/pseudo-tty/test-set-raw-mode-reset-process-exit.js
@@ -0,0 +1,18 @@
+'use strict';
+require('../common');
+const child_process = require('child_process');
+
+// Tests that exiting through process.exit() resets the TTY mode.
+
+child_process.spawnSync(process.execPath, [
+ '-e', 'process.stdin.setRawMode(true); process.exit(0)'
+], { stdio: 'inherit' });
+
+const { stdout } = child_process.spawnSync('stty', {
+ stdio: ['inherit', 'pipe', 'inherit'],
+ encoding: 'utf8'
+});
+
+if (stdout.match(/-echo\b/)) {
+ console.log(stdout);
+}