Skip to content

Commit

Permalink
test: add test for SIGWINCH handling by stdio.js
Browse files Browse the repository at this point in the history
PR-URL: #10063
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
sarahmeyer authored and MylesBorins committed Jan 31, 2017
1 parent 3eb9373 commit f1dea3f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';
const common = require('../common');

const originalRefreshSizeStderr = process.stderr._refreshSize;
const originalRefreshSizeStdout = process.stdout._refreshSize;

const wrap = (fn, ioStream, string) => {
return () => {
// The console.log() call prints a string that is in the .out file. In other
// words, the console.log() is part of the test, not extraneous debugging.
console.log(string);
try {
fn.call(ioStream);
} catch (e) {
// EINVAL happens on SmartOS if emulation is incomplete
if (!common.isSunOS || e.code !== 'EINVAL')
throw e;
}
};
};

process.stderr._refreshSize = wrap(originalRefreshSizeStderr,
process.stderr,
'calling stderr._refreshSize');
process.stdout._refreshSize = wrap(originalRefreshSizeStdout,
process.stdout,
'calling stdout._refreshSize');

process.emit('SIGWINCH');
2 changes: 2 additions & 0 deletions test/pseudo-tty/test-stderr-stdout-handle-sigwinch.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
calling stdout._refreshSize
calling stderr._refreshSize

0 comments on commit f1dea3f

Please sign in to comment.