From f1dea3fa4150ccaf272b81c0f5bbfd741d00fc51 Mon Sep 17 00:00:00 2001 From: Sarah Meyer Date: Thu, 1 Dec 2016 12:03:48 -0600 Subject: [PATCH] test: add test for SIGWINCH handling by stdio.js PR-URL: https://github.com/nodejs/node/pull/10063 Reviewed-By: James M Snell --- .../test-stderr-stdout-handle-sigwinch.js | 29 +++++++++++++++++++ .../test-stderr-stdout-handle-sigwinch.out | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js create mode 100644 test/pseudo-tty/test-stderr-stdout-handle-sigwinch.out diff --git a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js new file mode 100644 index 00000000000000..f1a95559b9dc92 --- /dev/null +++ b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js @@ -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'); diff --git a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.out b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.out new file mode 100644 index 00000000000000..dffbe030404487 --- /dev/null +++ b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.out @@ -0,0 +1,2 @@ +calling stdout._refreshSize +calling stderr._refreshSize