Skip to content

Commit

Permalink
Exit code (#27)
Browse files Browse the repository at this point in the history
* Update exit code due to mocha

* Fix exit code

* add window arg
  • Loading branch information
xudafeng committed Apr 25, 2016
1 parent 6c241fa commit b0a378a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 4 additions & 0 deletions bin/macaca-client
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ function init(error, data) {
process.exit('process exited with code ' + code);
});

bootstrap.on('exit', function(code) {
process.exit(code);
});

bootstrap.on('message', function(e) {
switch (e.signal) {
case 'kill':
Expand Down
3 changes: 2 additions & 1 deletion bin/macaca-client-run
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ runner.on('error', function(err) {
logger.warn(err);
});

runner.on('close', function() {
runner.on('close', function(code, signal) {
if (chunks) {
try {
var body = convert.toHtml(chunks.join(EOL));
Expand Down Expand Up @@ -130,4 +130,5 @@ runner.on('close', function() {
}
}
logger.info('Test completed!');
process.exit(code);
});
16 changes: 6 additions & 10 deletions lib/run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Runner.prototype.init = function(options) {

Runner.prototype.startServer = function() {
co(server, {
port: this.options.port
port: this.options.port,
window: this.options.window
}).then(() => {
this.isRunning = true;
this.initMocha();
Expand All @@ -56,17 +57,12 @@ Runner.prototype.initMocha = function() {
this.emit('data', data);
});

mocha.on('error', data => {
this.emit('error', data);
mocha.on('error', err => {
this.emit('error', err);
});

mocha.on('close', data => {
this.emit('close', data);
if (!this.options.always) {
process.send({
signal: 'kill'
});
}
mocha.on('close', (code, signal) => {
this.emit('close', code, signal);
});

this.mocha = mocha;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "macaca-client",
"version": "1.0.16",
"version": "1.0.18",
"description": "Macaca automation client",
"keywords": [
"automation",
Expand Down

0 comments on commit b0a378a

Please sign in to comment.