Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding a generic runner so all tests can be run.

This has been modified from
https://github.com/mikeal/request/blob/master/tests/run.js and modified in line
with the rest of my code.
  • Loading branch information...
commit 3b580a41fc4c239cef3b16221bf1acc3a39bf327 1 parent 23b50a8
@squeeks authored
Showing with 39 additions and 0 deletions.
  1. +39 −0 test/runner.js
View
39 test/runner.js
@@ -0,0 +1,39 @@
+var spawn = require('child_process').spawn(),
+ fs = require('fs'),
+ exitCode = 0,
+ timeout = 10000;
+
+fs.readdir(__dirname, function (e, files) {
+ if(e) throw e;
+
+ var tests = files.filter(function (f) {return f.slice(0, 'test-'.length) === 'test-'});
+
+ var next = function () {
+ if (tests.length === 0) process.exit(exitCode);
+
+ var file = tests.shift();
+ console.log(file);
+ var proc = spawn('node', [ 'test/' + 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) {
+ if (code && !killed) console.error(file + ' failed');
+ exitCode += code || 0;
+ clearTimeout(t);
+ next();
+ })
+ }
+ next();
+
+})
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.