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').
This commit is contained in:
parent
1bcd031ba2
commit
d7802123c1
|
@ -250,6 +250,24 @@ if (!program.outputHtml && !program.generateHtml) {
|
||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
if (test_json.num_fails > 0 || program.printAll) {
|
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) {
|
var traverse_tree = function(indentation, node) {
|
||||||
if (node.type == 'suite') {
|
if (node.type == 'suite') {
|
||||||
if (!node.has_subfailures && !program.printAll) return;
|
if (!node.has_subfailures && !program.printAll) return;
|
||||||
|
@ -281,7 +299,7 @@ if (!program.outputHtml && !program.generateHtml) {
|
||||||
cursor.magenta();
|
cursor.magenta();
|
||||||
console.log('- failed: '+node.text+test_json.replay);
|
console.log('- failed: '+node.text+test_json.replay);
|
||||||
cursor.red();
|
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();
|
cursor.reset();
|
||||||
console.log('');
|
console.log('');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue