[Pkg-javascript-commits] [node-tap-mocha-reporter] 39/137: Capture time of top level test from trailing comment

Bastien Roucariès rouca at moszumanska.debian.org
Thu Sep 7 09:49:24 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 1a4cc863bfe2b85ba97a7fb08267581c8302ca71
Author: isaacs <i at izs.me>
Date:   Wed Apr 29 15:21:46 2015 -0400

    Capture time of top level test from trailing comment
---
 lib/runner.js | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/runner.js b/lib/runner.js
index 89c4770..d056bed 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -47,6 +47,9 @@ var Suite = require('./suite.js')
 var Writable = require('stream').Writable
 var Parser = require('tap-parser')
 
+// $1 = number, $2 = units
+var timere = /^#\s*time=((?:0|[1-9][0-9]*?)(?:\.[0-9]+)?)(ms|s)?$/
+
 util.inherits(Runner, Writable)
 
 function Runner (options) {
@@ -90,6 +93,16 @@ function attachEvents (runner, parser, level) {
     parser.on('complete', function (res) {
       runner.emit('end')
     })
+    parser.on('comment', function (c) {
+      var tmatch = c.trim().match(timere)
+      if (tmatch) {
+        var t = +tmatch[1]
+        if (tmatch[2] === 's')
+          t *= 1000
+        parser.time = t
+        runner.stats.duration = t
+      }
+    })
   }
 
   parser.emittedSuite = false

-- 
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