test.js 539 B

12345678910111213141516171819202122
  1. var spawn = require('child_process').spawn,
  2. join = require('path').join;
  3. var files = require('fs').readdirSync(__dirname).filter(function(f) {
  4. return (f.substr(0, 5) === 'test-');
  5. }).map(function(f) {
  6. return join(__dirname, f);
  7. }),
  8. f = -1;
  9. function next() {
  10. if (++f < files.length) {
  11. spawn(process.argv[0], [ files[f] ], { stdio: 'inherit' })
  12. .on('exit', function(code) {
  13. if (code === 0)
  14. process.nextTick(next);
  15. else
  16. process.exit(code);
  17. });
  18. }
  19. }
  20. next();