mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 07:30:41 +09:00
Fix missing semicolons
Ensure all statements end with a semicolon.
This commit is contained in:
1 parent
34aaeee354
commit
29f066a191
56 files changed
+242
-242
No files matched your search
@@ -67,7 +67,7 @@ async function exec(...args) {
|
||||
}
|
||||
|
||||
async function sendRcon(instanceId, command) {
|
||||
let response = await link.messages.sendRcon.send(control, { instance_id: instanceId, command })
|
||||
let response = await link.messages.sendRcon.send(control, { instance_id: instanceId, command });
|
||||
return response.result;
|
||||
}
|
||||
|
||||
@@ -86,8 +86,8 @@ function spawn(name, cmd, waitFor) {
|
||||
resolve(process);
|
||||
}
|
||||
console.log(name, line);
|
||||
})
|
||||
let stderr = new server._LineSplitter((line) => { console.log(name, line.toString("utf8")); })
|
||||
});
|
||||
let stderr = new server._LineSplitter((line) => { console.log(name, line.toString("utf8")); });
|
||||
process.stdout.on("data", chunk => { stdout.data(chunk); });
|
||||
process.stdout.on("close", () => { stdout.end(); });
|
||||
process.stderr.on("data", chunk => { stderr.data(chunk); });
|
||||
|
||||
@@ -9,7 +9,7 @@ const { slowTest } = require("./index");
|
||||
|
||||
|
||||
// The server integration test is required to run before this one
|
||||
require("./server")
|
||||
require("./server");
|
||||
|
||||
describe("Integration of lib/factorio/patch", function() {
|
||||
describe("patch()", function() {
|
||||
|
||||
@@ -149,7 +149,7 @@ describe("Integration of lib/factorio/server", function() {
|
||||
slowTest(this);
|
||||
log(".startScenario()");
|
||||
|
||||
let pass = false
|
||||
let pass = false;
|
||||
function filter(output) {
|
||||
if (output.message === "test_scenario init") {
|
||||
pass = true;
|
||||
|
||||
+19
-19
@@ -97,13 +97,13 @@ describe("lib/config/classes", function() {
|
||||
enum: ["a", "b", "c"],
|
||||
optional: true,
|
||||
initial_value: "b",
|
||||
}
|
||||
};
|
||||
TestGroup.define(field);
|
||||
// Generated properties
|
||||
field.fullName = "test_group.enum";
|
||||
|
||||
assert.deepEqual(TestGroup._definitions.get("enum"), field);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("get definitions", function() {
|
||||
@@ -191,7 +191,7 @@ describe("lib/config/classes", function() {
|
||||
func: 22,
|
||||
bool: null,
|
||||
json: { valid: true },
|
||||
}})
|
||||
}});
|
||||
|
||||
assert.equal(testInstance.get("enum"), "c");
|
||||
assert.equal(testInstance.get("test"), "blah");
|
||||
@@ -218,7 +218,7 @@ describe("lib/config/classes", function() {
|
||||
alpha: null,
|
||||
beta: "decay",
|
||||
gamma: 99,
|
||||
}
|
||||
};
|
||||
|
||||
let testInstance = new TestGroup();
|
||||
await testInstance.load(null, { name: "test_group", fields: testFields });
|
||||
@@ -277,43 +277,43 @@ describe("lib/config/classes", function() {
|
||||
() => testInstance.set("bar", 1),
|
||||
new classes.InvalidField("No field named 'bar'")
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it("should throw if field is not in enum", function() {
|
||||
assert.throws(
|
||||
() => testInstance.set("enum", "bar"),
|
||||
new Error("Expected one of [a, b, c], not bar")
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it("should work if field is in enum", function() {
|
||||
testInstance.set("enum", "c"),
|
||||
assert.equal(testInstance.get("enum"), "c");
|
||||
})
|
||||
});
|
||||
|
||||
it("should throw if field is not optional", function() {
|
||||
assert.throws(
|
||||
() => testInstance.set("func", null),
|
||||
new Error("Field func cannot be null")
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it("should work if field is optional", function() {
|
||||
testInstance.set("test", "spam"),
|
||||
assert.equal(testInstance.get("test"), "spam");
|
||||
})
|
||||
});
|
||||
|
||||
it("should throw if field is of wrong type", function() {
|
||||
assert.throws(
|
||||
() => testInstance.set("test", 1),
|
||||
new Error("Expected type of test to be string, not number")
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it("should treat empty string as null", function() {
|
||||
testInstance.set("test", ""),
|
||||
assert.equal(testInstance.get("test"), null);
|
||||
})
|
||||
});
|
||||
|
||||
it("should auto convert string to boolean if possible", function() {
|
||||
testInstance.set("bool", "true");
|
||||
@@ -374,14 +374,14 @@ describe("lib/config/classes", function() {
|
||||
() => testInstance.setProp("bar", 1),
|
||||
new classes.InvalidField("No field named 'bar'")
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it("should throw if field is not an object", function() {
|
||||
assert.throws(
|
||||
() => testInstance.setProp("enum", "a"),
|
||||
new classes.InvalidField("Cannot set property on non-object field 'enum'")
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it("should work if field is an object", function() {
|
||||
testInstance.set("json", { prev: 32, test: false });
|
||||
@@ -461,7 +461,7 @@ describe("lib/config/classes", function() {
|
||||
await testInstance.init();
|
||||
assert.equal(testInstance.get("alpha.foo"), null);
|
||||
assert.deepEqual(testInstance.get("beta.bar"), {});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe(".serialize()", function() {
|
||||
@@ -480,7 +480,7 @@ describe("lib/config/classes", function() {
|
||||
}
|
||||
]
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe(".load()", function() {
|
||||
@@ -522,7 +522,7 @@ describe("lib/config/classes", function() {
|
||||
name: "beta",
|
||||
fields: { bar: { value: 20 }},
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
let testInstance = new TestConfig();
|
||||
await testInstance.load({ groups: testGroups });
|
||||
@@ -562,7 +562,7 @@ describe("lib/config/classes", function() {
|
||||
}
|
||||
],
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe(".group()", function() {
|
||||
@@ -580,14 +580,14 @@ describe("lib/config/classes", function() {
|
||||
let testInstance = new TestConfig();
|
||||
await testInstance.init();
|
||||
|
||||
assert.throws(() => testInstance.get("invalid"), new Error("No config group named 'invalid'"))
|
||||
assert.throws(() => testInstance.get("invalid"), new Error("No config group named 'invalid'"));
|
||||
});
|
||||
|
||||
it("should throw if no field is specified", async function() {
|
||||
let testInstance = new TestConfig();
|
||||
await testInstance.init();
|
||||
|
||||
assert.throws(() => testInstance.get("alpha"), new Error("No field named ''"))
|
||||
assert.throws(() => testInstance.get("alpha"), new Error("No field named ''"));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -228,13 +228,13 @@ describe("lib/database", function() {
|
||||
let items = new database.ItemDatabase();
|
||||
items.addItem("a", 10);
|
||||
assert.deepEqual(items._items, new Map([["a", 10]]));
|
||||
})
|
||||
});
|
||||
|
||||
it("should add an existing item", function() {
|
||||
let items = new database.ItemDatabase({"a": 10});
|
||||
items.addItem("a", 10);
|
||||
assert.deepEqual(items._items, new Map([["a", 20]]));
|
||||
})
|
||||
});
|
||||
|
||||
it("should throw on invalid name", function() {
|
||||
let items = new database.ItemDatabase();
|
||||
@@ -262,13 +262,13 @@ describe("lib/database", function() {
|
||||
let items = new database.ItemDatabase({"a": 20});
|
||||
items.removeItem("a", 10);
|
||||
assert.deepEqual(items._items, new Map([["a", 10]]));
|
||||
})
|
||||
});
|
||||
|
||||
it("should turn a non-existing item negative", function() {
|
||||
let items = new database.ItemDatabase();
|
||||
items.removeItem("a", 10);
|
||||
assert.deepEqual(items._items, new Map([["a", -10]]));
|
||||
})
|
||||
});
|
||||
|
||||
it("should throw on invalid name", function() {
|
||||
let items = new database.ItemDatabase();
|
||||
|
||||
@@ -142,8 +142,8 @@ let testLines = new Map([
|
||||
message: "Saving finished",
|
||||
}
|
||||
],
|
||||
])
|
||||
]);
|
||||
|
||||
module.exports = {
|
||||
testLines,
|
||||
}
|
||||
};
|
||||
@@ -213,7 +213,7 @@ describe("lib/factorio", function() {
|
||||
let zip = new jszip();
|
||||
zip.file("world/control.lua", "-- unknown\n");
|
||||
let zipPath = path.join("temp", "test", "patch.zip");
|
||||
await fs.outputFile(zipPath, await zip.generateAsync({type: "nodebuffer"}))
|
||||
await fs.outputFile(zipPath, await zip.generateAsync({type: "nodebuffer"}));
|
||||
|
||||
await assert.rejects(
|
||||
factorio.patch(zipPath, []),
|
||||
|
||||
@@ -84,7 +84,7 @@ describe("lib/factorio/server", function() {
|
||||
|
||||
describe("randomDynamicPort()", function() {
|
||||
it("should return a port number", function() {
|
||||
let port = factorio._randomDynamicPort()
|
||||
let port = factorio._randomDynamicPort();
|
||||
assert.equal(typeof port, "number");
|
||||
assert(Number.isInteger(port));
|
||||
assert(0 <= port && port < 2**16);
|
||||
@@ -203,25 +203,25 @@ describe("lib/factorio/server", function() {
|
||||
server._handleIpc(Buffer.from("\f$ipc:blah")),
|
||||
new Error('Malformed IPC line "\f$ipc:blah"')
|
||||
);
|
||||
})
|
||||
});
|
||||
it("should throw on unknown type", async function() {
|
||||
await assert.rejects(
|
||||
server._handleIpc(Buffer.from("\f$ipc:channel??")),
|
||||
new Error("Unknown IPC type '?'")
|
||||
);
|
||||
})
|
||||
});
|
||||
it("should throw on unknown file type", async function() {
|
||||
await assert.rejects(
|
||||
server._handleIpc(Buffer.from("\f$ipc:channel?ffoo.invalid")),
|
||||
new Error("Unknown IPC file format 'invalid'")
|
||||
);
|
||||
})
|
||||
});
|
||||
it("should throw on file name with slash", async function() {
|
||||
await assert.rejects(
|
||||
server._handleIpc(Buffer.from("\f$ipc:channel?fa/b")),
|
||||
new Error("Invalid IPC file name 'a/b'")
|
||||
);
|
||||
})
|
||||
});
|
||||
it("should load and delete json file", async function() {
|
||||
let filePath = server.writePath("script-output", "data.json");
|
||||
await fs.outputFile(filePath, '{"data":"spam"}');
|
||||
@@ -230,7 +230,7 @@ describe("lib/factorio/server", function() {
|
||||
let result = await waiter;
|
||||
assert.deepEqual(result[0], { "data": "spam" });
|
||||
assert(!await fs.pathExists(filePath), "File was not deleted");
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,7 @@ const assert = require("assert");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
|
||||
const generateSSLcert = require("lib/generateSSLcert")
|
||||
const generateSSLcert = require("lib/generateSSLcert");
|
||||
|
||||
describe("generateSSLcert.js(options)", ()=>{
|
||||
let testDir = path.join("temp", "test", "certTest");
|
||||
|
||||
@@ -97,7 +97,7 @@ describe("lib/link/link", function() {
|
||||
describe("._processHandler()", function() {
|
||||
it("should call the handler", function() {
|
||||
let handled = [];
|
||||
testLink.setHandler("handled", (message) => handled.push(message), (message) => true)
|
||||
testLink.setHandler("handled", (message) => handled.push(message), (message) => true);
|
||||
testLink._processHandler({ seq: 1, type: "handled", data: { test: "foo" } });
|
||||
assert.deepEqual(handled, [{ seq: 1, type: "handled", data: { test: "foo" } }]);
|
||||
});
|
||||
|
||||
@@ -163,6 +163,6 @@ describe("lib/link/messages", function() {
|
||||
describe("attachAllMessages()", function() {
|
||||
it("does not throw", function() {
|
||||
link.attachAllMessages(testSourceLink);
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
+4
-4
@@ -14,7 +14,7 @@ describe("lib/plugin", function() {
|
||||
it("should be constructible", async function() {
|
||||
instancePlugin = new plugin.BaseInstancePlugin();
|
||||
await instancePlugin.init();
|
||||
})
|
||||
});
|
||||
it("should define defaults for hooks", async function() {
|
||||
await instancePlugin.onMetrics();
|
||||
await instancePlugin.onStart();
|
||||
@@ -23,7 +23,7 @@ describe("lib/plugin", function() {
|
||||
await instancePlugin.onOutput({});
|
||||
instancePlugin.onMasterConnectionEvent("connect");
|
||||
await instancePlugin.onPrepareMasterDisconnect();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("class BaseMasterPlugin", function() {
|
||||
@@ -31,14 +31,14 @@ describe("lib/plugin", function() {
|
||||
it("should be constructible", async function() {
|
||||
masterPlugin = new plugin.BaseMasterPlugin();
|
||||
await masterPlugin.init();
|
||||
})
|
||||
});
|
||||
it("should define defaults for hooks", async function() {
|
||||
await masterPlugin.onInstanceStatusChanged({}, "running", "initialized");
|
||||
await masterPlugin.onMetrics();
|
||||
await masterPlugin.onShutdown();
|
||||
masterPlugin.onSlaveConnectionEvent({}, "connect");
|
||||
await masterPlugin.onPrepareSlaveDisconnect({});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("loadPluginInfos()", function() {
|
||||
|
||||
+15
-15
@@ -8,7 +8,7 @@ describe("lib/prometheus", function() {
|
||||
let registry;
|
||||
beforeEach(function() {
|
||||
registry = new prometheus.CollectorRegistry();
|
||||
})
|
||||
});
|
||||
|
||||
describe(".register()", function() {
|
||||
it("should register a collector", function() {
|
||||
@@ -208,7 +208,7 @@ describe("lib/prometheus", function() {
|
||||
name, "Help", { register: false }
|
||||
),
|
||||
new Error(`Invalid name '${name}'`)
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
it("should throw on invalid label names", function() {
|
||||
@@ -218,7 +218,7 @@ describe("lib/prometheus", function() {
|
||||
"test", "Help", { register: false, labels: [name] }
|
||||
),
|
||||
new Error(`Invalid label '${name}'`)
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
it("should throw on missing name", function() {
|
||||
@@ -336,7 +336,7 @@ describe("lib/prometheus", function() {
|
||||
gauge.labels("1", "3");
|
||||
gauge.labels("4", "6");
|
||||
gauge.removeAll({a: "1"});
|
||||
assert(gauge._values.size <= 1, "Matching labels remained")
|
||||
assert(gauge._values.size <= 1, "Matching labels remained");
|
||||
assert(
|
||||
gauge._values.has('a="4",b="6"'),
|
||||
"Non-matching label was removed"
|
||||
@@ -351,10 +351,10 @@ describe("lib/prometheus", function() {
|
||||
it("should handle special characters", function() {
|
||||
let gauge = new prometheus.Gauge(
|
||||
"test", "Help", { register: false, labels: ["a", "b"] }
|
||||
)
|
||||
);
|
||||
gauge.labels('x\\\\\n\"\"\n\\', "2");
|
||||
gauge.removeAll({a: 'x\\\\\n\"\"\n\\'});
|
||||
assert(gauge._values.size === 0, "Matching labels remained")
|
||||
assert(gauge._values.size === 0, "Matching labels remained");
|
||||
});
|
||||
});
|
||||
describe(".clear()", function() {
|
||||
@@ -381,7 +381,7 @@ describe("lib/prometheus", function() {
|
||||
describe("processStartTimeSeconds", function() {
|
||||
it("should give a close point in time", async function() {
|
||||
this.skip(); // XXX Doesn't work in Clusterio's shared testing env
|
||||
let results = []
|
||||
let results = [];
|
||||
let collector = prometheus.defaultCollectors.processStartTimeSeconds;
|
||||
for await (let result of collector.collect()) {
|
||||
results.push(result);
|
||||
@@ -401,7 +401,7 @@ describe("lib/prometheus", function() {
|
||||
describe("processCpuSecondsTotal", function() {
|
||||
it("should give a low value", async function() {
|
||||
this.skip(); // XXX Doesn't work in Clusterio's shared testing env
|
||||
let results = []
|
||||
let results = [];
|
||||
let collector = prometheus.defaultCollectors.processCpuSecondsTotal;
|
||||
for await (let result of collector.collect()) {
|
||||
results.push(result);
|
||||
@@ -412,7 +412,7 @@ describe("lib/prometheus", function() {
|
||||
"collector did not give exactly one result"
|
||||
);
|
||||
|
||||
let value = results[0].samples.get("")
|
||||
let value = results[0].samples.get("");
|
||||
assert(
|
||||
value < 5 && value > 0,
|
||||
`process time is not between 0 and 5 seconds (${value})`
|
||||
@@ -422,7 +422,7 @@ describe("lib/prometheus", function() {
|
||||
describe("processResidentMemoryBytes", function() {
|
||||
it("should give a low value", async function() {
|
||||
this.skip(); // XXX Doesn't work in Clusterio's shared testing env
|
||||
let results = []
|
||||
let results = [];
|
||||
let collector = prometheus.defaultCollectors.processResidentMemoryBytes;
|
||||
for await (let result of collector.collect()) {
|
||||
results.push(result);
|
||||
@@ -433,7 +433,7 @@ describe("lib/prometheus", function() {
|
||||
"collector did not give exactly one result"
|
||||
);
|
||||
|
||||
let value = results[0].samples.get("")
|
||||
let value = results[0].samples.get("");
|
||||
assert(
|
||||
value < 200e6 && value > 0,
|
||||
`resident memory is not between 0 and 200 MB (${value})`
|
||||
@@ -443,7 +443,7 @@ describe("lib/prometheus", function() {
|
||||
describe("processHeapBytes", function() {
|
||||
it("should give a low value", async function() {
|
||||
this.skip(); // XXX Doesn't work in Clusterio's shared testing env
|
||||
let results = []
|
||||
let results = [];
|
||||
let collector = prometheus.defaultCollectors.processHeapBytes;
|
||||
for await (let result of collector.collect()) {
|
||||
results.push(result);
|
||||
@@ -454,7 +454,7 @@ describe("lib/prometheus", function() {
|
||||
"collector did not give exactly one result"
|
||||
);
|
||||
|
||||
let value = results[0].samples.get("")
|
||||
let value = results[0].samples.get("");
|
||||
assert(
|
||||
value < 200e6 && value > 0,
|
||||
`heap is not between 0 and 200 MB (${value})`
|
||||
@@ -533,7 +533,7 @@ describe("lib/prometheus", function() {
|
||||
assert.deepEqual(
|
||||
prometheus.serializeResult(deserializedResult),
|
||||
serializedResult
|
||||
)
|
||||
);
|
||||
});
|
||||
it("should support adding labels", function() {
|
||||
assert.deepEqual(
|
||||
@@ -595,7 +595,7 @@ describe("lib/prometheus", function() {
|
||||
assert.deepEqual(
|
||||
prometheus.deserializeResult(serializedResult),
|
||||
deserializedResult
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -66,10 +66,10 @@ class MockInstance extends link.Link {
|
||||
this.name = "test";
|
||||
this.config = {
|
||||
get: (name) => {
|
||||
if (name === "instance.id") { return 7357 }
|
||||
if (name === "instance.id") { return 7357; }
|
||||
throw Error("Not implemented");
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -23,16 +23,16 @@ describe("Slave testing", function() {
|
||||
describe(".name", function() {
|
||||
it("should give the name of the instance", function() {
|
||||
assert.equal(instance.name, "foo");
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe(".path()", function() {
|
||||
it("should give the path when called without arguments", function() {
|
||||
assert.equal(instance.path(), "dir");
|
||||
})
|
||||
});
|
||||
it("should join path with arguments", function() {
|
||||
assert.equal(instance.path("bar"), path.join("dir", "bar"));
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ describe("Slave testing", function() {
|
||||
let discardingLogger = {
|
||||
warning: function() { },
|
||||
log: function() { },
|
||||
}
|
||||
};
|
||||
|
||||
let instance;
|
||||
before(async function() {
|
||||
|
||||
Reference in new issue
Block a user