Permalink
Browse files

Support `if main`

  • Loading branch information...
1 parent 804d874 commit c65a58d3e710d7842ea6a2fe1fcc6e2659e7def6 @5long committed Nov 6, 2010
Showing with 4 additions and 2 deletions.
  1. +2 −0 example/all_in_one.js
  2. +2 −2 src/runner.js
View
@@ -2,6 +2,8 @@ var reut = require("reut")
, EE = require("events").EventEmitter
, fs = require("fs")
+if (module == require.main) process.nextTick(reut.run)
+
reut.suite("A suite to contain 'em all")
.setup(function(fixture, done) {
fixture.answer = 42
View
@@ -23,15 +23,15 @@ var runner = module.exports = {
}
, run: function(opt, cb) {
if (arguments.length < 2) cb = opt
- var reporters = opt.reporters || defaultReporters
+ var reporters = opt && opt.reporters || defaultReporters
async.paraMap(suites, function(suite) {
reporters.forEach(function(r) {
suite.reportTo(r)
})
suite.run(this)
}, function(err, result) {
process.emit("_reutTestEnd")
- cb.apply(this, arguments)
+ cb && cb.apply(this, arguments)
})
}
, _suites: suites

0 comments on commit c65a58d

Please sign in to comment.