0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js
Rich Trott 8c68def5ff test: require handler to be run in sigwinch test
Use `common.mustCall()` to guarantee that the wrapped `_refreshSize()`
functions are invoked.

PR-URL: https://github.com/nodejs/node/pull/11068
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michal Zasso <targos@protonmail.com>
2017-01-31 10:31:21 -08:00

31 lines
1.0 KiB
JavaScript

'use strict';
const common = require('../common');
const originalRefreshSizeStderr = process.stderr._refreshSize;
const originalRefreshSizeStdout = process.stdout._refreshSize;
const wrap = (fn, ioStream, string) => {
const wrapped = common.mustCall(() => {
// 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;
}
});
return wrapped;
};
process.stderr._refreshSize = wrap(originalRefreshSizeStderr,
process.stderr,
'calling stderr._refreshSize');
process.stdout._refreshSize = wrap(originalRefreshSizeStdout,
process.stdout,
'calling stdout._refreshSize');
process.emit('SIGWINCH');