Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using custom @screeps/common fork to avoid restarting common/storage process #35

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
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
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@screeps/driver/-/driver-5.1.0.tgz#2f36bf30998e4be83de7a342859add2dd595889e"
Expand Down