From 7a6fec4cd5597ae7dc3c6aaba732237759ce03a9 Mon Sep 17 00:00:00 2001 From: Devon Campbell Date: Thu, 9 Nov 2017 09:44:07 -0800 Subject: [PATCH] Ensures errors in stdoutEqual callback are logged Since stdout is redirected while the callback is executed, any errors the callback throws are suppressed and never logged. This unhooks `process.stdout.write` after catching an error in `callback()` and re-throws it so it will be logged. --- test/jshint_test.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/jshint_test.js b/test/jshint_test.js index e687733..fd56d2f 100644 --- a/test/jshint_test.js +++ b/test/jshint_test.js @@ -21,7 +21,12 @@ var stdoutEqual = function(callback, done) { } }); // Execute the logging code to be tested. - callback(); + try { + callback(); + } catch (error) { + hooker.unhook(process.stdout, 'write'); + throw error; + } // Restore process.stdout.write to its original value. hooker.unhook(process.stdout, 'write'); // Actually test the actually-logged stdout string to the expected value.