Permalink
Browse files

Change SummaryReporter behavior

  • Loading branch information...
1 parent aef7773 commit 804d874c84ce08fb9d691a24f100199a69c0006d @5long committed Nov 6, 2010
Showing with 14 additions and 9 deletions.
  1. +1 −6 src/bin/cli.js
  2. +1 −1 src/reporter/summary.js
  3. +11 −2 src/runner.js
  4. +1 −0 test/reporter_summary.js
View
@@ -3,11 +3,6 @@ var runner = require("../runner")
, util = require("../util")
, async = util.async
, path = require("path")
- , reporterMod = require("../reporter")
- , reporters = [ new reporterMod.Failure()
- , new reporterMod.Summary()
- , new reporterMod.Error()
- ]
function main() {
var files = util.makeArray(process.argv, 2)
@@ -17,7 +12,7 @@ function main() {
loadAndRun(path.join(cwd, file), this)
}, function(err) {
if (err) throw err
- runner.run({reporters:reporters}, function(err) {
+ runner.run({}, function(err) {
if (err) throw err
})
})
@@ -6,7 +6,7 @@ function SummaryReporter(writable) {
var self = this
this._output = writable || process.stdout
this._result = {all: [], passed: [], failed: []}
- process.on("exit", function() {
+ process.on("_reutTestEnd", function() {
self._report()
})
}
View
@@ -3,6 +3,12 @@ var TestSuite = require("./test_suite")
, Test = require("./test")
, async = require("./util").async
, suites = []
+ , reporterMod = require("./reporter")
+ , defaultReporters = [
+ new reporterMod.Failure()
+ , new reporterMod.Summary()
+ , new reporterMod.Error()
+ ]
// TODO Extract the test runner interface.
var runner = module.exports = {
@@ -17,13 +23,16 @@ var runner = module.exports = {
}
, run: function(opt, cb) {
if (arguments.length < 2) cb = opt
- var reporters = opt.reporters || []
+ var reporters = opt.reporters || defaultReporters
async.paraMap(suites, function(suite) {
reporters.forEach(function(r) {
suite.reportTo(r)
})
suite.run(this)
- }, cb)
+ }, function(err, result) {
+ process.emit("_reutTestEnd")
+ cb.apply(this, arguments)
+ })
}
, _suites: suites
}
@@ -20,6 +20,7 @@ dummySuite.run(function(err) {
})
process.on("exit", function() {
+ process.emit("_reutTestEnd")
var output = spyWritable.input[0]
, num = sampleTest.num
assert.notEqual(output.indexOf(num.all), -1)

0 comments on commit 804d874

Please sign in to comment.