[gjs: 2/4] minijasmine: Comment error message lines instead of replacing newlines




commit 2526f6f18f54e20b41fa4ed028b3ce90cd1f110d
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Wed Jun 8 18:48:34 2022 +0200

    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 5b7885dd6..09a099ae8 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}`));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]