UT: More work on detecting standalone server exit.

This commit is contained in:
Arthur Britto
2013-01-12 12:48:18 -08:00
parent 3b66a13646
commit 8c5f08ad9b
3 changed files with 30 additions and 5 deletions

View File

@@ -98,6 +98,10 @@ Server.prototype._serverSpawnSync = function() {
// By default, just log exits.
this.child.on('exit', function(code, signal) {
if (!self.quiet) console.log("server: spawn: server exited code=%s: signal=%s", code, signal);
self.emit('exited');
// Workaround for
// https://github.com/busterjs/buster/issues/266
if (!self.stopping) {
@@ -108,8 +112,6 @@ Server.prototype._serverSpawnSync = function() {
// If regular exit: code=0, signal=null
// Fail the test if the server has not called "stop".
buster.assert(self.stopping, 'Server died with signal '+signal);
if (!self.quiet) console.log("server: spawn: server exited code=%s: signal=%s", code, signal);
});
};

View File

@@ -90,10 +90,22 @@ var build_setup = function (opts, host) {
function runServerStep(callback) {
if (opts.no_server) return callback();
data.server = Server.from_config(host, !!opts.verbose_server).on('started', callback).start();
data.server = Server
.from_config(host, !!opts.verbose_server)
.on('started', callback)
.on('exited', function () {
// If know the remote, tell it server is gone.
if (self.remote)
self.remote.server_fatal();
})
.start();
},
function connectWebsocketStep(callback) {
self.remote = data.remote = Remote.from_config(host, !!opts.verbose_ws).once('ledger_closed', callback).connect();
self.remote = data.remote =
Remote
.from_config(host, !!opts.verbose_ws)
.once('ledger_closed', callback)
.connect();
}
], done);
};