From 837d9a91cd1493a7b58deadcc8c3860a6e0ab18c Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Mon, 4 Apr 2016 15:47:13 -0400 Subject: [PATCH 1/2] Use only console.log in terminal outpt `console.error` does not always have the same buffering settings as `console.log` and so printing to both does not always cause output to be shown in the intended order. `console.error` should only be used for real errors that happen elsewhere. --- output_generators/terminal.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/output_generators/terminal.js b/output_generators/terminal.js index c663385..7419269 100644 --- a/output_generators/terminal.js +++ b/output_generators/terminal.js @@ -35,17 +35,17 @@ function prettyPrintResult( result ){ case 'fail': var color = (result.progress === 'regression') ? 'red' : 'yellow'; - console.error( + console.log( util.format( ' ✘ %s[%s] "%s": %s', status, id, testDescription, result.msg )[ color ] ); break; case 'placeholder': - console.error( util.format( ' ! [%s] "%s": %s', id, testDescription, result.msg ).cyan ); + console.log( util.format( ' ! [%s] "%s": %s', id, testDescription, result.msg ).cyan ); break; default: - console.error( util.format( 'Result type `%s` not recognized.', result.result ) ); + console.log( util.format( 'Result type `%s` not recognized.', result.result ) ); process.exit( 1 ); break; } @@ -67,8 +67,8 @@ function prettyPrintSuiteResults( suiteResults, config, testSuites ){ console.log( '\nAggregate test results'.blue ); console.log( 'Pass: ' + suiteResults.stats.pass.toString().green ); - console.error( 'Fail: ' + suiteResults.stats.fail.toString().yellow ); - console.error( 'Placeholders: ' + suiteResults.stats.placeholder.toString().cyan ); + console.log( 'Fail: ' + suiteResults.stats.fail.toString().yellow ); + console.log( 'Placeholders: ' + suiteResults.stats.placeholder.toString().cyan ); var numRegressions = suiteResults.stats.regression; var regressionsColor = ( numRegressions > 0 ) ? 'red' : 'yellow'; @@ -81,7 +81,7 @@ function prettyPrintSuiteResults( suiteResults, config, testSuites ){ console.log( '' ); if( numRegressions > 0 ){ - console.error( 'FATAL ERROR: %s regression(s) detected.'.red.inverse, numRegressions ); + console.log( 'FATAL ERROR: %s regression(s) detected.'.red.inverse, numRegressions ); return 1; } else { From 996b1e784bc90a5cd116b7322d0fe8871a5a0fbb Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Mon, 4 Apr 2016 16:22:19 -0400 Subject: [PATCH 2/2] Set exit code variable without calling process.exit `process.exit` quits immediately, without allowing buffered output from say, a `console.log` to be printed. See these Node.js issues: https://github.com/nodejs/node/issues/3669 https://github.com/nodejs/node/pull/3170 https://github.com/nodejs/node/issues/2972#issuecomment-146078649 --- bin/fuzzy-tester | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/fuzzy-tester b/bin/fuzzy-tester index 8bf4db2..085bffe 100755 --- a/bin/fuzzy-tester +++ b/bin/fuzzy-tester @@ -29,7 +29,7 @@ var analyze_results = require( '../lib/analyze_results' ); // display results using the correct output generator var return_code = config.outputGenerator(evaled_results, config, testSuites); - process.exit(return_code); + process.exitCode = return_code; }; // find all test suites and test cases that will be run