mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
test/server.js asserts on exit that stop() has been called (to detect improper exit)
This commit is contained in:
@@ -9,7 +9,7 @@ var alpha;
|
|||||||
|
|
||||||
buster.testCase("Standalone server startup", {
|
buster.testCase("Standalone server startup", {
|
||||||
"server start and stop" : function (done) {
|
"server start and stop" : function (done) {
|
||||||
alpha = Server.from_config("alpha",true);
|
alpha = Server.from_config("alpha"); //ADD ,true for verbosity
|
||||||
|
|
||||||
alpha
|
alpha
|
||||||
.on('started', function () {
|
.on('started', function () {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ var Server = function (name, config, verbose) {
|
|||||||
this.config = config;
|
this.config = config;
|
||||||
this.started = false;
|
this.started = false;
|
||||||
this.quiet = !verbose;
|
this.quiet = !verbose;
|
||||||
|
this.stopping = false; //Not sure if we need this...
|
||||||
};
|
};
|
||||||
|
|
||||||
Server.prototype = new EventEmitter;
|
Server.prototype = new EventEmitter;
|
||||||
@@ -99,6 +100,7 @@ Server.prototype._serverSpawnSync = function() {
|
|||||||
this.child.on('exit', function(code, signal) {
|
this.child.on('exit', function(code, signal) {
|
||||||
// If could not exec: code=127, signal=null
|
// If could not exec: code=127, signal=null
|
||||||
// If regular exit: code=0, signal=null
|
// If regular exit: code=0, signal=null
|
||||||
|
buster.assert(!self.stopping); //Fail the test if the server is exiting without having called "stop"
|
||||||
if (!self.quiet) console.log("server: spawn: server exited code=%s: signal=%s", code, signal);
|
if (!self.quiet) console.log("server: spawn: server exited code=%s: signal=%s", code, signal);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -148,7 +150,7 @@ Server.prototype.start = function () {
|
|||||||
// Stop a standalone server.
|
// Stop a standalone server.
|
||||||
Server.prototype.stop = function () {
|
Server.prototype.stop = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
self.stopping = true; //Tell the caller that the server is properly stopping.
|
||||||
if (this.child) {
|
if (this.child) {
|
||||||
// Update the on exit to invoke done.
|
// Update the on exit to invoke done.
|
||||||
this.child.on('exit', function (code, signal) {
|
this.child.on('exit', function (code, signal) {
|
||||||
|
|||||||
Reference in New Issue
Block a user