Skip to content

Commit

Permalink
Add more reporting to tests
Browse files Browse the repository at this point in the history
This was useful for me when I was testing `request` with `streams2`.
  • Loading branch information
mmalecki committed Dec 30, 2012
1 parent d734337 commit 11a3bc0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/run.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var spawn = require('child_process').spawn
, exitCode = 0
, timeout = 10000
;

var tests = [
Expand Down Expand Up @@ -35,11 +36,22 @@ var next = function () {
var file = tests.shift()
console.log(file)
var proc = spawn('node', [ 'tests/' + file ])

var killed = false
var t = setTimeout(function () {
proc.kill()
exitCode += 1
console.error(file + ' timeout')
killed = true
}, timeout)

proc.stdout.pipe(process.stdout)
proc.stderr.pipe(process.stderr)
proc.on('exit', function (code) {
exitCode += code || 0
next()
if (code && !killed) console.error(file + ' failed')
exitCode += code || 0
clearTimeout(t)
next()
})
}
next()

0 comments on commit 11a3bc0

Please sign in to comment.