Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: check TTY mode reset on exit #21027

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions test/pseudo-tty/test-set-raw-mode-reset-process-exit.js
Original file line number Diff line number Diff line change
@@ -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);
}
Empty file.
24 changes: 24 additions & 0 deletions test/pseudo-tty/test-set-raw-mode-reset-signal.js
Original file line number Diff line number Diff line change
@@ -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);
}
}));
Empty file.
19 changes: 19 additions & 0 deletions test/pseudo-tty/test-set-raw-mode-reset.js
Original file line number Diff line number Diff line change
@@ -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);
}
1 change: 1 addition & 0 deletions test/pseudo-tty/test-set-raw-mode-reset.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@