mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
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>
This commit is contained in:
parent
48a2568f41
commit
7c8eec0648
18
test/pseudo-tty/test-set-raw-mode-reset-process-exit.js
Normal file
18
test/pseudo-tty/test-set-raw-mode-reset-process-exit.js
Normal file
@ -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);
|
||||
}
|
24
test/pseudo-tty/test-set-raw-mode-reset-signal.js
Normal file
24
test/pseudo-tty/test-set-raw-mode-reset-signal.js
Normal file
@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const child_process = require('child_process');
|
||||
|
||||
// Tests that exiting through a catchable signal resets the TTY mode.
|
||||
|
||||
const proc = child_process.spawn(process.execPath, [
|
||||
'-e', 'process.stdin.setRawMode(true); console.log("Y"); while(true) {}'
|
||||
], { stdio: ['inherit', 'pipe', 'inherit'] });
|
||||
|
||||
proc.stdout.on('data', common.mustCall(() => {
|
||||
proc.kill('SIGINT');
|
||||
}));
|
||||
|
||||
proc.on('exit', common.mustCall(() => {
|
||||
const { stdout } = child_process.spawnSync('stty', {
|
||||
stdio: ['inherit', 'pipe', 'inherit'],
|
||||
encoding: 'utf8'
|
||||
});
|
||||
|
||||
if (stdout.match(/-echo\b/)) {
|
||||
console.log(stdout);
|
||||
}
|
||||
}));
|
0
test/pseudo-tty/test-set-raw-mode-reset-signal.out
Normal file
0
test/pseudo-tty/test-set-raw-mode-reset-signal.out
Normal file
19
test/pseudo-tty/test-set-raw-mode-reset.js
Normal file
19
test/pseudo-tty/test-set-raw-mode-reset.js
Normal file
@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
const child_process = require('child_process');
|
||||
|
||||
// Tests that exiting through normal means resets the TTY mode.
|
||||
// Refs: https://github.com/nodejs/node/issues/21020
|
||||
|
||||
child_process.spawnSync(process.execPath, [
|
||||
'-e', 'process.stdin.setRawMode(true)'
|
||||
], { stdio: 'inherit' });
|
||||
|
||||
const { stdout } = child_process.spawnSync('stty', {
|
||||
stdio: ['inherit', 'pipe', 'inherit'],
|
||||
encoding: 'utf8'
|
||||
});
|
||||
|
||||
if (stdout.match(/-echo\b/)) {
|
||||
console.log(stdout);
|
||||
}
|
0
test/pseudo-tty/test-set-raw-mode-reset.out
Normal file
0
test/pseudo-tty/test-set-raw-mode-reset.out
Normal file
Loading…
Reference in New Issue
Block a user