From b275024a3e385ad90c1475bbab351cea97a6fcd0 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Wed, 3 Aug 2011 17:09:45 +0700 Subject: [PATCH] [isolate] implement runner --- bin/vows | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/bin/vows b/bin/vows index 222a86f..cddcc15 100755 --- a/bin/vows +++ b/bin/vows @@ -384,7 +384,36 @@ function runSuites(suites, callback) { function importSuites(files) { msg(options.watcher ? 'watcher' : 'runner', 'loading', files); - return files.reduce(function (suites, f) { + var exec = require('child_process').exec; + + function wrapExec(f) { + return function(options, callback) { + var cmd = process.argv.slice(0, 2).concat('--json'); + + exec(cmd.join(' '), function (err, stdout, stderr) { + if (err) { + reporter.report(['error', stderr]); + callback({ + errored: 1, + total: 1 + }); + return; + } + + var result = stdout.split(/\n/g).map(function(i) { + if (i) { + reporter.report(JSON.parse(i)); + } + }); + }) + } + } + + return files.reduce(options.isolate ? function (suites, f) { + return suites.concat({ + run: wrapExec(f) + }); + } : function (suites, f) { var obj = require(f); return suites.concat(Object.keys(obj).map(function (s) { obj[s]._filename = f.replace(process.cwd() + '/', '') + '.js';