Skip to content

Commit

Permalink
Console Logging the info and error output from ScreepsServer
Browse files Browse the repository at this point in the history
  • Loading branch information
brisberg committed Aug 7, 2020
1 parent 7939136 commit ec8eea1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
24 changes: 24 additions & 0 deletions test/basics.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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 = {
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions utils/stdhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
},
Expand Down

0 comments on commit ec8eea1

Please sign in to comment.