From ff12d9adaab51bfc5d27bad160e3f60e5098fa96 Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Sun, 5 Jan 2014 13:09:42 +0700 Subject: [PATCH] Run server-test and websocket-test first. Show stderr upon abnormal rippled exit --- package.json | 2 +- test/mocha.opts | 5 ++++- test/runall.sh | 2 +- test/server.js | 14 +++++++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index acb01a70d..3a02361ff 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "scripts": { - "test": "mocha test/*-test.{js,coffee}" + "test": "mocha" }, "repository": { diff --git a/test/mocha.opts b/test/mocha.opts index 77a7a3544..880fa5702 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -2,4 +2,7 @@ --compilers coffee:coffee-script --ui tdd --timeout 10000 ---slow 600 \ No newline at end of file +--slow 600 +test/server-test.js +test/websocket-test.js +test/*-test.{js,coffee} \ No newline at end of file diff --git a/test/runall.sh b/test/runall.sh index 2e31c8d2f..24fb30c8f 100755 --- a/test/runall.sh +++ b/test/runall.sh @@ -1,4 +1,4 @@ #!/bin/bash # flags set in mocha.opts -mocha test/*-test.{js,coffee} \ No newline at end of file +mocha \ No newline at end of file diff --git a/test/server.js b/test/server.js index 4b694677f..050a55bc1 100644 --- a/test/server.js +++ b/test/server.js @@ -91,7 +91,7 @@ Server.prototype._serverSpawnSync = function() { var options = { cwd: this.serverPath(), env: process.env, - stdio: this.quiet ? 'ignore' : 'inherit' + stdio: this.quiet ? 'pipe': 'inherit' }; // Spawn in standalone mode for now. @@ -103,6 +103,10 @@ Server.prototype._serverSpawnSync = function() { this.config.rippled_path, args.join(" "), this.configPath()); + + + var stderr = []; + self.child.stderr.on('data', function(buf) { stderr.push(buf); }); // By default, just log exits. this.child.on('exit', function(code, signal) { @@ -110,6 +114,14 @@ Server.prototype._serverSpawnSync = function() { self.emit('exited'); + // Dump server logs on an abnormal exit + if (self.quiet && (!self.stopping)) { + process.stderr.write("rippled stderr:\n"); + for (var i = 0; i < stderr.length; i++) { + process.stderr.write(stderr[i]); + }; + }; + // If could not exec: code=127, signal=null // If regular exit: code=0, signal=null // Fail the test if the server has not called "stop".