From ba6dcee9dc0fda627096d873ab65b7e35712a78b Mon Sep 17 00:00:00 2001 From: brisberg Date: Tue, 16 Jun 2020 10:54:12 -0700 Subject: [PATCH 1/3] Console Logging the info and error output from ScreepsServer --- test/basics.tests.js | 24 ++++++++++++++++++++++++ utils/stdhooks.js | 6 +++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/test/basics.tests.js b/test/basics.tests.js index 730974c..1b344db 100644 --- a/test/basics.tests.js +++ b/test/basics.tests.js @@ -16,6 +16,12 @@ suite('Basics tests', function () { test('Starting server and running a few ticks without error', async function () { server = new ScreepsServer(); + server.on('error', (msg) => { + console.log(`error: ${msg}`) + }); + server.on('info', (msg) => { + console.log(`info: ${msg}`) + }); await server.start(); for (let i = 0; i < 5; i += 1) { await server.tick(); @@ -32,6 +38,12 @@ suite('Basics tests', function () { mainLoopResetInterval: 10000, }; server = new ScreepsServer(opts); + server.on('error', (msg) => { + console.log(`error: ${msg}`) + }); + server.on('info', (msg) => { + console.log(`info: ${msg}`) + }); // Assert if options are correctly registered assert.equal(server.opts.path, opts.path); assert.equal(server.opts.logdir, opts.logdir); @@ -49,6 +61,12 @@ suite('Basics tests', function () { test('Running user code', async function () { // Server initialization server = new ScreepsServer(); + server.on('error', (msg) => { + console.log(`error: ${msg}`) + }); + server.on('info', (msg) => { + console.log(`info: ${msg}`) + }); await server.world.stubWorld(); // Code declaration const modules = { @@ -75,6 +93,12 @@ suite('Basics tests', function () { test('Getting current tick', async function () { // Server initialization server = new ScreepsServer(); + server.on('error', (msg) => { + console.log(`error: ${msg}`) + }); + server.on('info', (msg) => { + console.log(`info: ${msg}`) + }); await server.world.reset(); assert.equal(await server.world.gameTime, 1); // Run a few ticks and assert if tick is correct diff --git a/utils/stdhooks.js b/utils/stdhooks.js index 3cc8016..d2c9856 100644 --- a/utils/stdhooks.js +++ b/utils/stdhooks.js @@ -13,9 +13,9 @@ module.exports = { return stdout.apply(this, args); }; process.stderr.write = function (...args) { - if (args[0].match(/storage connection lost/i)) { - return 0; - } + // if (args[0].match(/storage connection lost/i)) { + // return 0; + // } return stdout.apply(this, args); }; }, From bdce4b1de55b458b730a535e1db26740a901a886 Mon Sep 17 00:00:00 2001 From: brisberg Date: Thu, 25 Jun 2020 07:26:18 -0700 Subject: [PATCH 2/3] Using @brisberg/common to cleanly close the test server --- package.json | 1 + yarn.lock | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/package.json b/package.json index 88c2ee7..110ea26 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "test": "mocha --ui tdd --exit" }, "dependencies": { + "@screeps/common": "github:brisberg/common#no-storage-restart", "fs-extra-promise": "^1.0.1", "lodash": "^4.17.15", "screeps": "^4.1.5" diff --git a/yarn.lock b/yarn.lock index 446dd34..04c3fb7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -163,6 +163,14 @@ lodash "^3.10.1" q "^1.4.1" +"@screeps/common@github:brisberg/common#no-storage-restart": + version "2.14.0" + resolved "https://codeload.github.com/brisberg/common/tar.gz/27c09c2b5c740954c776d709d4c71346cc239ded" + dependencies: + eslint "^5.12.1" + lodash "^3.10.1" + q "^1.4.1" + "@screeps/driver@5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@screeps/driver/-/driver-5.1.0.tgz#2f36bf30998e4be83de7a342859add2dd595889e" From acbc24aa2ae63c159191d0219c777885727b5128 Mon Sep 17 00:00:00 2001 From: brisberg Date: Fri, 7 Aug 2020 15:07:11 -0700 Subject: [PATCH 3/3] Fixed lint issues --- test/basics.tests.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/basics.tests.js b/test/basics.tests.js index 1b344db..7aa1a9a 100644 --- a/test/basics.tests.js +++ b/test/basics.tests.js @@ -17,10 +17,10 @@ suite('Basics tests', function () { test('Starting server and running a few ticks without error', async function () { server = new ScreepsServer(); server.on('error', (msg) => { - console.log(`error: ${msg}`) + console.log(`error: ${msg}`); }); server.on('info', (msg) => { - console.log(`info: ${msg}`) + console.log(`info: ${msg}`); }); await server.start(); for (let i = 0; i < 5; i += 1) { @@ -39,10 +39,10 @@ suite('Basics tests', function () { }; server = new ScreepsServer(opts); server.on('error', (msg) => { - console.log(`error: ${msg}`) + console.log(`error: ${msg}`); }); server.on('info', (msg) => { - console.log(`info: ${msg}`) + console.log(`info: ${msg}`); }); // Assert if options are correctly registered assert.equal(server.opts.path, opts.path); @@ -62,10 +62,10 @@ suite('Basics tests', function () { // Server initialization server = new ScreepsServer(); server.on('error', (msg) => { - console.log(`error: ${msg}`) + console.log(`error: ${msg}`); }); server.on('info', (msg) => { - console.log(`info: ${msg}`) + console.log(`info: ${msg}`); }); await server.world.stubWorld(); // Code declaration @@ -94,10 +94,10 @@ suite('Basics tests', function () { // Server initialization server = new ScreepsServer(); server.on('error', (msg) => { - console.log(`error: ${msg}`) + console.log(`error: ${msg}`); }); server.on('info', (msg) => { - console.log(`info: ${msg}`) + console.log(`info: ${msg}`); }); await server.world.reset(); assert.equal(await server.world.gameTime, 1);