[Pkg-javascript-commits] [node-tap-mocha-reporter] 10/137: node-tap will produce cleaned-up stacks. Revive them to js-like status

Bastien Roucariès rouca at moszumanska.debian.org
Thu Sep 7 09:49:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-tap-mocha-reporter.

commit 79a0d92a13a193a32e88903b223de910d59db770
Author: isaacs <i at izs.me>
Date:   Sat Apr 25 11:02:37 2015 -0700

    node-tap will produce cleaned-up stacks. Revive them to js-like status
---
 lib/runner.js | 42 +++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/lib/runner.js b/lib/runner.js
index 87c6756..251feae 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -203,27 +203,39 @@ function emitTest (parser, result) {
 }
 
 function getError (result) {
-  if (result.diag && result.diag.error)
-    return result.diag.error
+  var err
 
-  var err = {
-    message: (result.name || '(unnamed error)').replace(/^Error: /, ''),
-    toString: function () {
-      return 'Error: ' + this.message
-    }
+  function reviveStack (stack) {
+    if (!stack)
+      return null
+
+    return stack.trim().split('\n').map(function (line) {
+      return '    at ' + line
+    }).join('\n')
   }
 
-  if (result.diag.stack) {
-    if (Array.isArray(result.diag.stack)) {
-      err.stack = err.toString() + '\n' +
-        result.diag.stack.map(function (s) {
-          return '    at ' + s
-        }).join('\n')
-    } else if (typeof result.diag.stack === 'string') {
-      err.stack = result.diag.stack
+  if (result.diag && result.diag.error) {
+    err = {
+      name: result.diag.error.name || 'Error',
+      message: result.diag.error.message,
+      toString: function () {
+        return this.name + ': ' + this.message
+      },
+      stack: result.diag.error.stack
+    }
+  } else {
+    err = {
+      message: (result.name || '(unnamed error)').replace(/^Error: /, ''),
+      toString: function () {
+        return 'Error: ' + this.message
+      },
+      stack: result.diag.stack
     }
   }
 
+  if (err.stack)
+    err.stack = err.toString() + '\n' + reviveStack(err.stack)
+
   var hasFound = Object.prototype.hasOwnProperty.call(result, 'found')
   var hasWanted = Object.prototype.hasOwnProperty.call(result, 'wanted')
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-tap-mocha-reporter.git



More information about the Pkg-javascript-commits mailing list