Skip to content

Commit

Permalink
Using portfinder to get a magic grover server port
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Sep 8, 2012
1 parent 720ba09 commit 63aec11
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 31 deletions.
71 changes: 40 additions & 31 deletions lib/cmds/test.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var log = require('../log'),
util = require('../util'), util = require('../util'),
git = require('../git'), git = require('../git'),
path = require('path'), path = require('path'),
portfinder = require('portfinder'),
fs = require('fs'), fs = require('fs'),
spawn = require('child_process').spawn, //comma spawn = require('child_process').spawn, //comma
mods = { mods = {
Expand Down Expand Up @@ -310,40 +311,48 @@ mods = {
tests.unshift('--suffix'); tests.unshift('--suffix');
} }


tests.unshift('--server');

if (this.options.parsed.t) {
tests.unshift(this.options.parsed.t);
tests.unshift('--timeout');
}
if (this.options.parsed.c) {
tests.unshift(this.options.parsed.c);
tests.unshift('--concurrent');
}
log.debug('executing testing in:\n' + tests.join('\n'));
grover = spawn(groverBin, tests, {
cwd: gbase
});

grover.stdout.on('data', function (data) {
log.log(data.toString().trim());
});


grover.stderr.on('data', function (data) { portfinder.getPort(function (err, port) {
data = data.toString().trim();
if (data.indexOf('Failed to parse') === -1) { log.debug('setting grover port to ' + port);
log.error('grover: ' + data); tests.unshift(port);
} tests.unshift('--port');
}); tests.unshift('--server');

grover.on('exit', function(code) { if (self.options.parsed.t) {
if (code) { tests.unshift(self.options.parsed.t);
log.bail('grover returned a failure'); tests.unshift('--timeout');
} }
log.info('grover tests complete'.green); if (self.options.parsed.c) {
if (callback) { tests.unshift(self.options.parsed.c);
callback(); tests.unshift('--concurrent');
} }
log.debug('executing testing in:\n' + tests.join('\n'));
grover = spawn(groverBin, tests, {
cwd: gbase
});

grover.stdout.on('data', function (data) {
log.log(data.toString().trim());
});

grover.stderr.on('data', function (data) {
data = data.toString().trim();
if (data.indexOf('Failed to parse') === -1) {
log.error('grover: ' + data);
}
});

grover.on('exit', function(code) {
if (code) {
log.bail('grover returned a failure');
}
log.info('grover tests complete'.green);
if (callback) {
callback();
}
});

}); });


}, },
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"osenv": "*", "osenv": "*",
"yui-lint": "*", "yui-lint": "*",
"shifter": ">=0.0.10", "shifter": ">=0.0.10",
"portfinder": "*",
"editor": "https://github.com/dominictarr/node-editor/tarball/master" "editor": "https://github.com/dominictarr/node-editor/tarball/master"
}, },
"scripts": { "scripts": {
Expand Down

0 comments on commit 63aec11

Please sign in to comment.