Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2bbd99c

Browse filesBrowse files
committed
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: #21020 Refs: #20592 PR-URL: #21027 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 4012e05 commit 2bbd99c
Copy full SHA for 2bbd99c
Expand file treeCollapse file tree

6 files changed

+61
-0
lines changed
Open diff view settings
Collapse file
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
require('../common');
3+
const child_process = require('child_process');
4+
5+
// Tests that exiting through process.exit() resets the TTY mode.
6+
7+
child_process.spawnSync(process.execPath, [
8+
'-e', 'process.stdin.setRawMode(true); process.exit(0)'
9+
], { stdio: 'inherit' });
10+
11+
const { stdout } = child_process.spawnSync('stty', {
12+
stdio: ['inherit', 'pipe', 'inherit'],
13+
encoding: 'utf8'
14+
});
15+
16+
if (stdout.match(/-echo\b/)) {
17+
console.log(stdout);
18+
}
Collapse file

‎test/pseudo-tty/test-set-raw-mode-reset-process-exit.out‎

Copy file name to clipboardExpand all lines: test/pseudo-tty/test-set-raw-mode-reset-process-exit.out
Whitespace-only changes.
Collapse file
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
const common = require('../common');
3+
const child_process = require('child_process');
4+
5+
// Tests that exiting through a catchable signal resets the TTY mode.
6+
7+
const proc = child_process.spawn(process.execPath, [
8+
'-e', 'process.stdin.setRawMode(true); console.log("Y"); while(true) {}'
9+
], { stdio: ['inherit', 'pipe', 'inherit'] });
10+
11+
proc.stdout.on('data', common.mustCall(() => {
12+
proc.kill('SIGINT');
13+
}));
14+
15+
proc.on('exit', common.mustCall(() => {
16+
const { stdout } = child_process.spawnSync('stty', {
17+
stdio: ['inherit', 'pipe', 'inherit'],
18+
encoding: 'utf8'
19+
});
20+
21+
if (stdout.match(/-echo\b/)) {
22+
console.log(stdout);
23+
}
24+
}));
Collapse file

‎test/pseudo-tty/test-set-raw-mode-reset-signal.out‎

Copy file name to clipboardExpand all lines: test/pseudo-tty/test-set-raw-mode-reset-signal.out
Whitespace-only changes.
Collapse file
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
require('../common');
3+
const child_process = require('child_process');
4+
5+
// Tests that exiting through normal means resets the TTY mode.
6+
// Refs: https://github.com/nodejs/node/issues/21020
7+
8+
child_process.spawnSync(process.execPath, [
9+
'-e', 'process.stdin.setRawMode(true)'
10+
], { stdio: 'inherit' });
11+
12+
const { stdout } = child_process.spawnSync('stty', {
13+
stdio: ['inherit', 'pipe', 'inherit'],
14+
encoding: 'utf8'
15+
});
16+
17+
if (stdout.match(/-echo\b/)) {
18+
console.log(stdout);
19+
}
Collapse file

‎test/pseudo-tty/test-set-raw-mode-reset.out‎

Copy file name to clipboardExpand all lines: test/pseudo-tty/test-set-raw-mode-reset.out
Whitespace-only changes.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.