[Pkg-javascript-commits] [node-tap-mocha-reporter] 38/137: Roll back time stuff

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 9d2a81d4e92049250a7f543cfde9ab4e748f3747
Author: isaacs <i at izs.me>
Date:   Tue Apr 28 11:03:22 2015 -0400

    Roll back time stuff
    
    Screws up the root suite names and 'suite end' events.
---
 lib/runner.js | 49 +++++++++++++------------------------------------
 1 file changed, 13 insertions(+), 36 deletions(-)

diff --git a/lib/runner.js b/lib/runner.js
index 2f46713..89c4770 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -46,7 +46,6 @@ var Test = require('./test.js')
 var Suite = require('./suite.js')
 var Writable = require('stream').Writable
 var Parser = require('tap-parser')
-var timere = /^#\s*time=((?:0|[1-9][0-9]*)(:?\.[0-9]+)?)(ms|s)?\n$/
 
 util.inherits(Runner, Writable)
 
@@ -89,12 +88,13 @@ function attachEvents (runner, parser, level) {
       runner.emit('version', v)
     })
     parser.on('complete', function (res) {
-      runner.emit('end', runner.stats)
+      runner.emit('end')
     })
   }
 
   parser.emittedSuite = false
   parser.didAssert = false
+  parser.printed = false
   parser.name = ''
   parser.doingChild = null
 
@@ -123,6 +123,7 @@ function attachEvents (runner, parser, level) {
   })
 
   parser.on('child', function (child) {
+    //console.log('>>> child')
     child.parent = parser
     attachEvents(runner, child, level + 1)
 
@@ -137,22 +138,9 @@ function attachEvents (runner, parser, level) {
   })
 
   parser.on('comment', function (c) {
-    if (c.match(/^# Subtest: /)) {
+    if (!this.printed && c.match(/^# Subtest: /)) {
       c = c.trim().replace(/^# Subtest: /, '')
-      parser.name = c.trim()
-    }
-
-    // get the top-level duration from the trailing comment,
-    // if one occurs.
-    if (!this.suite || this.suite.root) {
-      var m = c.match(timere)
-      if (m) {
-        var time = m[1]
-        if (m[2] === 's')
-          time *= 1000
-
-        runner.stats.duration = Math.round(time, 0)
-      }
+      this.name = c
     }
   })
 
@@ -162,17 +150,12 @@ function attachEvents (runner, parser, level) {
   })
 
   parser.on('assert', function (result) {
-    emitSuite(this, result)
+    emitSuite(this)
 
     // no need to print the trailing assert for subtests
-    // just do a 'suite end' event for this.
+    // we've already emitted a 'suite end' event for this.
     if (this.doingChild && this.doingChild.didAssert &&
         this.doingChild.name === result.name) {
-      var suite = this.doingChild.suite
-      if (suite) {
-        suite.duration = Math.round(result.time, 0)
-        runner.emit('suite end', this.doingChild.suite)
-      }
       this.doingChild = null
       return
     }
@@ -185,6 +168,8 @@ function attachEvents (runner, parser, level) {
 
   parser.on('complete', function (results) {
     this.results = results
+    if (this.suite)
+      runner.emit('suite end', this.suite)
   })
 
   parser.on('bailout', function (reason) {
@@ -208,14 +193,13 @@ function attachEvents (runner, parser, level) {
   })
 }
 
-function emitSuite (parser, result) {
-  if (!parser.emittedSuite && (parser.name || parser.level === 0)) {
+function emitSuite (parser) {
+  //console.log('emitSuite', parser.emittedSuite, parser.level, parser.name)
+  if (!parser.emittedSuite && parser.name) {
     parser.emittedSuite = true
     var suite = parser.suite = new Suite(parser)
-    if (parser.parent && parser.parent.suite) {
+    if (parser.parent && parser.parent.suite)
       parser.parent.suite.suites.push(suite)
-    }
-
     parser.runner.emit('suite', suite)
   }
 }
@@ -224,17 +208,10 @@ function emitTest (parser, result) {
   var runner = parser.runner
   var test = new Test(result, parser)
 
-  if (!parser.suite) {
-    emitSuite(parser, result)
-  }
-
-
   if (parser.suite) {
     //if (test.parent === parser)
     //  test.parent = parser.suite
     parser.suite.tests.push(test)
-  } else {
-    console.error('test without suite?')
   }
 
   runner.emit('test', test)

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