Permalink
Browse files

Adding some yeti goodness to yogi

  • Loading branch information...
1 parent 7ae35ca commit 58a765e41b25ed4e640ad5de5331f4da3ed91682 @davglass davglass committed Sep 19, 2012
Showing with 100 additions and 25 deletions.
  1. +3 −0 lib/args.js
  2. +96 −25 lib/cmds/test.js
  3. +1 −0 package.json
View
@@ -14,6 +14,9 @@ var util = require('./util'),
x: Array,
cli: Boolean,
coverage: Boolean,
+ yeti: Boolean,
+ hub: String,
+ connected: Boolean,
istanbul: Boolean,
config: path,
version: Boolean,
View
@@ -18,6 +18,10 @@ mods = {
}
this.options = options;
+
+ this.useYeti = options.parsed.yeti;
+ this.yetiHub = options.parsed.hub || 'http://hub.davglass.com:80/';
+ this.yetiAgents = options.parsed.agents;
this.filter = options.parsed.filter;
@@ -46,21 +50,29 @@ mods = {
}
this.module = module;
- this.prepGrover(function(port) {
- if (options.parsed.cli) {
- self.cli(port, function() {
- self.killGrover();
- });
+ if (this.yetiHub && this.useYeti) {
+ if (this.yetiAgents) {
+ this.agents();
} else {
- if (options.parsed.cli === false) {
- self.grover();
- } else {
+ this.yeti();
+ }
+ } else {
+ this.prepGrover(function(port) {
+ if (options.parsed.cli) {
self.cli(port, function() {
- self.grover();
+ self.killGrover();
});
+ } else {
+ if (options.parsed.cli === false) {
+ self.grover();
+ } else {
+ self.cli(port, function() {
+ self.grover();
+ });
+ }
}
- }
- });
+ });
+ }
},
buildYUI: function(callback) {
log.info('installing yui to create npm package');
@@ -217,27 +229,65 @@ mods = {
this.groverProcess.send({ 'continue': true });
},
groverProcess: null,
- prepGrover: function(callback) {
- log.info('prepping grover tests');
- var groverBin = path.join(__dirname, '../../node_modules/.bin/grover'),
- tests = [], base, hasCoverage = [], parts = [], tmp,
+ agents: function() {
+ log.info('fetching yeti agents from ' + this.yetiHub);
+ var yeti = require('yeti'),
+ self = this,
+ client = yeti.createClient(this.yetiHub);
+
+ client.connect(function() {
+ client.getAgents(function(err, agents) {
+ log.info('hub currently has ' + agents.length + ' connected agents');
+ agents.sort().forEach(function(a) {
+ console.log(' ', a);
+ });
+ client.end();
+ });
+ });
+ },
+ yeti: function() {
+ var tests = this.resolveTests(),
+ yetiBin = path.join(__dirname, '../../node_modules/.bin/yeti'),
+ gbase = path.join(git.findRoot(), '../'),
+ child, self = this;
+
+ log.info('using hub: ' + this.yetiHub);
+
+ log.debug('setting server root to: ' + gbase);
+ log.info('starting yeti output\n');
+ tests.forEach(function(val, key) {
+ tests[key] = val.replace(gbase, '');
+ });
+ process.chdir(gbase);
+
+ tests.unshift(self.yetiHub);
+ tests.unshift('--hub');
+
+ child = spawn(yetiBin, tests, {
+ cwd: gbase,
+ stdio: 'inherit'
+ });
+
+ child.on('exit', function(code) {
+ if (code) {
+ log.bail('yeti tests failed');
+ }
+ log.info('yeti tests complete');
+ });
+ },
+ resolveTests: function() {
+ var tests = [], base,
gbase = path.join(git.findRoot(), '../'),
- self = this, files, batch, grover,
+ self = this, files, batch,
exclude = {},
testPath = path.join(this.module.dir, 'tests', 'unit');
- if (!util.exists(groverBin)) {
- log.bail('grover is not installed :(');
- }
-
if (this.options.parsed.x) {
this.options.parsed.x.forEach(function(m) {
exclude[m] = true;
});
}
log.debug('scanning ' + testPath);
- log.debug('setting server root to: ' + gbase);
- process.chdir(gbase);
if (util.exists(testPath)) {
tests = util.getTests(testPath, self.coverage);
@@ -277,6 +327,25 @@ mods = {
}
}
+ return tests;
+ },
+ prepGrover: function(callback) {
+ log.info('prepping grover tests');
+ var groverBin = path.join(__dirname, '../../node_modules/.bin/grover'),
+ tests = [],
+ gbase = path.join(git.findRoot(), '../'),
+ self = this, grover,
+ exclude = {};
+
+ if (!util.exists(groverBin)) {
+ log.bail('grover is not installed :(');
+ }
+
+ log.debug('setting server root to: ' + gbase);
+ process.chdir(gbase);
+
+ tests = this.resolveTests();
+
tests.forEach(function(val, key) {
tests[key] = val.replace(gbase, '');
});
@@ -313,8 +382,7 @@ mods = {
}
log.debug('executing testing in:\n' + tests.join('\n'));
grover = fork(groverBin, tests, {
- cwd: gbase,
-
+ cwd: gbase
});
self.groverProcess = grover;
@@ -348,7 +416,10 @@ mods = {
'from ./src to test all',
'--coverage to generate a coverage report',
'--cli to run only cli tests',
- '--filter (min|raw|debug) pass filter to test files'
+ '--filter (min|raw|debug) pass filter to test files',
+ '--yeti Will run tests on http://hub.davglass.com (experimental)',
+ '--yeti --hub <url> Use this hub instead (experimental)',
+ '--yeti --agents List the agents connected to the hub (experimental)'
];
}
};
View
@@ -26,6 +26,7 @@
"portfinder": "*",
"echoecho": "*",
"istanbul": "*",
+ "yeti": "http://latest.yeti.cx/",
"editor": "https://github.com/dominictarr/node-editor/tarball/master"
},
"scripts": {

0 comments on commit 58a765e

Please sign in to comment.