From 2526f6f18f54e20b41fa4ed028b3ce90cd1f110d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 8 Jun 2022 18:48:34 +0200 Subject: minijasmine: Comment error message lines instead of replacing newlines Error message lines were removed from test logs, but this makes them harder to read. So just use the same strategy we use for the stack trace, by just commenting out the lines for having a proper TAP report. --- installed-tests/js/minijasmine.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/installed-tests/js/minijasmine.js b/installed-tests/js/minijasmine.js index 5b7885dd..09a099ae 100644 --- a/installed-tests/js/minijasmine.js +++ b/installed-tests/js/minijasmine.js @@ -4,11 +4,6 @@ const GLib = imports.gi.GLib; -function _removeNewlines(str) { - let allNewlines = /\n/g; - return str.replace(allNewlines, '\\n'); -} - function _filterStack(stack) { if (!stack) return 'No stack'; @@ -89,7 +84,9 @@ class TapReporter { if (result.status === 'failed' && result.failedExpectations) { result.failedExpectations.forEach(failedExpectation => { const output = []; - output.push(`Message: ${_removeNewlines(failedExpectation.message)}`); + const messageLines = failedExpectation.message.split('\n'); + output.push(`Message: ${messageLines.shift()}`); + output.push(...messageLines.map(str => ` ${str}`)); output.push('Stack:'); let stackTrace = _filterStack(failedExpectation.stack).trim(); output.push(...stackTrace.split('\n').map(str => ` ${str}`)); -- cgit v1.2.1