diff options
author | Solly Ross <sross@redhat.com> | 2015-05-28 15:09:31 -0400 |
---|---|---|
committer | Solly Ross <sross@redhat.com> | 2015-08-06 14:47:03 -0400 |
commit | b0b5fc55e1fe5c575855104e9ce6df79329a8db7 (patch) | |
tree | 7f0fb19ed1fb4d5d93a9e474b4abd53670269e30 | |
parent | 07f514d887c27369f7675296a2cb1cb6d664cd91 (diff) | |
download | novnc-b0b5fc55e1fe5c575855104e9ce6df79329a8db7.tar.gz |
Fix multi-line assertion messages in test runner
This commit prevents multi-line error messages from being
truncated in the local test runner ('tests/run_from_console.js').
-rwxr-xr-x | tests/run_from_console.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/run_from_console.js b/tests/run_from_console.js index f5c5bb4..371e861 100755 --- a/tests/run_from_console.js +++ b/tests/run_from_console.js @@ -250,6 +250,24 @@ if (!program.outputHtml && !program.generateHtml) { console.log(''); if (test_json.num_fails > 0 || program.printAll) { + var extract_error_lines = function (err) { + // the split is to avoid a weird thing where in PhantomJS where we get a stack trace too + var err_lines = err.split('\n'); + if (err_lines.length == 1) { + return err_lines[0]; + } else { + var ind; + for (ind = 0; ind < err_lines.length; ind++) { + var at_ind = err_lines[ind].trim().indexOf('at '); + if (at_ind === 0) { + break; + } + } + + return err_lines.slice(0, ind).join('\n'); + } + }; + var traverse_tree = function(indentation, node) { if (node.type == 'suite') { if (!node.has_subfailures && !program.printAll) return; @@ -281,7 +299,7 @@ if (!program.outputHtml && !program.generateHtml) { cursor.magenta(); console.log('- failed: '+node.text+test_json.replay); cursor.red(); - console.log(' '+node.error.split("\n")[0]); // the split is to avoid a weird thing where in PhantomJS where we get a stack trace too + console.log(' '+extract_error_lines(node.error)); cursor.reset(); console.log(''); } |