[go: nahoru, domu]

Skip to content

Commit

Permalink
Fix multi-line assertion messages in test runner
Browse files Browse the repository at this point in the history
This commit prevents multi-line error messages from being
truncated in the local test runner ('tests/run_from_console.js').
  • Loading branch information
DirectXMan12 committed Aug 6, 2015
1 parent 07f514d commit b0b5fc5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/run_from_console.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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('');
}
Expand Down

0 comments on commit b0b5fc5

Please sign in to comment.