From 7f4f91b75b5c4eb1253a64a70883e18f14fab995 Mon Sep 17 00:00:00 2001 From: Sarah Meyer Date: Thu, 1 Dec 2016 12:03:48 -0600 Subject: [PATCH 1/4] add test coverage for SIGWINCH in stdio.js --- .../test-stderr-stdout-handle-sigwinch.js | 17 +++++++++++++++++ .../test-stderr-stdout-handle-sigwinch.out | 2 ++ 2 files changed, 19 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..f837435a7e0312 --- /dev/null +++ b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js @@ -0,0 +1,17 @@ +'use strict'; +require('../common'); + +// if printing, add to out file + +const refreshSizeWrapperStderr = () => { + console.log('calling stderr._refreshSize'); +}; + +const refreshSizeWrapperStdout = () => { + console.log('calling stdout._refreshSize'); +}; + +process.stderr._refreshSize = refreshSizeWrapperStderr; +process.stdout._refreshSize = refreshSizeWrapperStdout; + +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 From 1fb5d71ecc492d3ad2185fe5caadcefed31d4653 Mon Sep 17 00:00:00 2001 From: Sarah Meyer Date: Thu, 1 Dec 2016 13:16:46 -0600 Subject: [PATCH 2/4] test: adding test coverage for SIGWINCH in stdio.js, call original function from wrapper --- test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js index f837435a7e0312..bd4974469d455f 100644 --- a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js +++ b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js @@ -2,13 +2,17 @@ require('../common'); // if printing, add to out file +const originalRefreshSizeWrapperStderr = process.stderr._refreshSize; +const originalRefreshSizeWrapperStdout = process.stdout._refreshSize; const refreshSizeWrapperStderr = () => { console.log('calling stderr._refreshSize'); + originalRefreshSizeWrapperStderr.call(process.stderr); }; const refreshSizeWrapperStdout = () => { console.log('calling stdout._refreshSize'); + originalRefreshSizeWrapperStdout.call(process.stdout); }; process.stderr._refreshSize = refreshSizeWrapperStderr; From 04fb7e108e6fa0a6d55df2a2c6a8fa11eeda25a6 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 25 Dec 2016 16:33:14 -0800 Subject: [PATCH 3/4] squash: adding exception for EINVAL on SmartOS --- .../test-stderr-stdout-handle-sigwinch.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js index bd4974469d455f..40a2c7d4d44227 100644 --- a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js +++ b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); // if printing, add to out file const originalRefreshSizeWrapperStderr = process.stderr._refreshSize; @@ -7,12 +7,24 @@ const originalRefreshSizeWrapperStdout = process.stdout._refreshSize; const refreshSizeWrapperStderr = () => { console.log('calling stderr._refreshSize'); - originalRefreshSizeWrapperStderr.call(process.stderr); + try { + originalRefreshSizeWrapperStderr.call(process.stderr); + } catch (e) { + // EINVAL happens on SmartOS if emulation is incomplete + if (!common.isSunOS || e.code !== 'EINVAL') + throw e; + } }; const refreshSizeWrapperStdout = () => { console.log('calling stdout._refreshSize'); - originalRefreshSizeWrapperStdout.call(process.stdout); + try { + originalRefreshSizeWrapperStdout.call(process.stdout); + } catch (e) { + // EINVAL happens on SmartOS if emulation is incomplete + if (!common.isSunOS || e.code !== 'EINVAL') + throw e; + } }; process.stderr._refreshSize = refreshSizeWrapperStderr; From d4cafa0aab1c1099508b1aecbcae2957293d718e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 26 Dec 2016 22:35:44 -0800 Subject: [PATCH 4/4] squash: comment explaining the console.log() --- .../test-stderr-stdout-handle-sigwinch.js | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js index 40a2c7d4d44227..f1a95559b9dc92 100644 --- a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js +++ b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js @@ -1,33 +1,29 @@ 'use strict'; const common = require('../common'); -// if printing, add to out file -const originalRefreshSizeWrapperStderr = process.stderr._refreshSize; -const originalRefreshSizeWrapperStdout = process.stdout._refreshSize; +const originalRefreshSizeStderr = process.stderr._refreshSize; +const originalRefreshSizeStdout = process.stdout._refreshSize; -const refreshSizeWrapperStderr = () => { - console.log('calling stderr._refreshSize'); - try { - originalRefreshSizeWrapperStderr.call(process.stderr); - } catch (e) { - // EINVAL happens on SmartOS if emulation is incomplete - if (!common.isSunOS || e.code !== 'EINVAL') - throw e; - } +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; + } + }; }; -const refreshSizeWrapperStdout = () => { - console.log('calling stdout._refreshSize'); - try { - originalRefreshSizeWrapperStdout.call(process.stdout); - } catch (e) { - // EINVAL happens on SmartOS if emulation is incomplete - if (!common.isSunOS || e.code !== 'EINVAL') - throw e; - } -}; - -process.stderr._refreshSize = refreshSizeWrapperStderr; -process.stdout._refreshSize = refreshSizeWrapperStdout; +process.stderr._refreshSize = wrap(originalRefreshSizeStderr, + process.stderr, + 'calling stderr._refreshSize'); +process.stdout._refreshSize = wrap(originalRefreshSizeStdout, + process.stdout, + 'calling stdout._refreshSize'); process.emit('SIGWINCH');