Skip to content

Commit

Permalink
Fix #34 Treat timeouts as a proper failure
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Dec 29, 2011
1 parent 8682bc3 commit 4ef2b40
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/tap-runner.js
Expand Up @@ -179,8 +179,9 @@ Runner.prototype.runFiles = function (files, dir, cb) {
, tc = new TapConsumer()
, childTests = [f]

setTimeout(function () {
var timeout = setTimeout(function () {
if (!cp._ended) {
cp._timedOut = true
cp.kill()
console.error("killing: " + f + " (timed out)")
}
Expand All @@ -195,12 +196,16 @@ Runner.prototype.runFiles = function (files, dir, cb) {
cp.stdout.on("data", function(c) { out += c })
cp.stderr.on("data", function(c) { err += c })

cp.on("exit", function(code) {
cp.on("exit", function (code) {
cp._ended = true
var ok = !cp._timedOut && !code
clearTimeout(timeout)
//childTests.forEach(function (c) { self.write(c) })
var res = { name: path.dirname(f).replace(process.cwd() + "/", "")
+ "/" + fileName
, ok: !code }
, ok: ok
, timedOut: cp._timedOut
, exit: code }

if (err) {
res.stderr = err
Expand Down

0 comments on commit 4ef2b40

Please sign in to comment.