mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 16:13:12 +09:00
Merge remote-tracking branch 'origin/master' into plugin-minimap
This commit is contained in:
commit
979d961618
131 files changed
+6585
-2515
No files matched your search
+26
-15
@@ -119,15 +119,14 @@ class TestHostConnector extends lib.WebSocketClientConnector {
|
||||
}
|
||||
}
|
||||
|
||||
// Mark that this test takes a lot of time, or depeneds on a test
|
||||
// that takes a lot of time.
|
||||
// Mark that this test takes a lot of time, or depends on a test that takes a lot of time.
|
||||
function slowTest(test) {
|
||||
|
||||
if (process.env.FAST_TEST) {
|
||||
test.skip();
|
||||
}
|
||||
|
||||
test.timeout(20000);
|
||||
test.timeout(30000);
|
||||
}
|
||||
|
||||
async function get(urlPath) {
|
||||
@@ -176,29 +175,31 @@ let controllerConfigPath = path.join("temp", "test", "config-controller.json");
|
||||
let hostConfigPath = path.join("temp", "test", "config-host.json");
|
||||
let controlConfigPath = path.join("temp", "test", "config-control.json");
|
||||
|
||||
async function exec(command, options = {}) {
|
||||
function exec(command, options = {}) {
|
||||
// Uncomment to show commands run in tests
|
||||
// console.log(command);
|
||||
options = { cwd: path.join("temp", "test"), ...options };
|
||||
return await util.promisify(child_process.exec)(command, options);
|
||||
return util.promisify(child_process.exec)(command, options);
|
||||
}
|
||||
|
||||
async function execController(...args) {
|
||||
function execController(...args) {
|
||||
args[0] = `node --enable-source-maps ../../packages/controller ${args[0]}`;
|
||||
return await exec(...args);
|
||||
return exec(...args);
|
||||
}
|
||||
|
||||
async function execHost(...args) {
|
||||
function execHost(...args) {
|
||||
args[0] = `node --enable-source-maps ../../packages/host ${args[0]}`;
|
||||
return await exec(...args);
|
||||
return exec(...args);
|
||||
}
|
||||
|
||||
async function execCtlProcess(...args) {
|
||||
function execCtlProcess(...args) {
|
||||
args[0] = `node --enable-source-maps ../../packages/ctl ${args[0]}`;
|
||||
return await exec(...args);
|
||||
return exec(...args);
|
||||
}
|
||||
|
||||
let inExecCtl = false;
|
||||
async function execCtl(command) {
|
||||
inExecCtl = true;
|
||||
process.chdir("temp/test");
|
||||
try {
|
||||
const initArgs = await initializeCtl(command, control.plugins, true);
|
||||
@@ -211,9 +212,17 @@ async function execCtl(command) {
|
||||
await targetCommand.run(initArgs.args, control);
|
||||
} finally {
|
||||
process.chdir("../..");
|
||||
inExecCtl = false;
|
||||
}
|
||||
}
|
||||
|
||||
afterEach(function() {
|
||||
if (inExecCtl) {
|
||||
// This is needed in case a test times out and never runs the finally block
|
||||
process.chdir("../..");
|
||||
}
|
||||
});
|
||||
|
||||
async function sendRcon(instanceId, command) {
|
||||
return await control.sendTo({ instanceId }, new lib.InstanceSendRconRequest(command));
|
||||
}
|
||||
@@ -222,7 +231,8 @@ function getControl() {
|
||||
return control;
|
||||
}
|
||||
|
||||
function spawn(name, cmd, waitFor) {
|
||||
/** @returns {Promise<child_process.ChildProcess>} */
|
||||
function spawn(name, cmd, waitFor, options = {}) {
|
||||
|
||||
const silent = process.env.SILENT_TEST;
|
||||
const bootstrap = !controllerProcess || !hostProcess;
|
||||
@@ -235,7 +245,7 @@ function spawn(name, cmd, waitFor) {
|
||||
return new Promise((resolve, reject) => {
|
||||
log(cmd);
|
||||
let parts = cmd.split(" ");
|
||||
let process = child_process.spawn(parts[0], parts.slice(1), { cwd: path.join("temp", "test") });
|
||||
let process = child_process.spawn(parts[0], parts.slice(1), { cwd: path.join("temp", "test"), ...options });
|
||||
let stdout = new LineSplitter({ readableObjectMode: true });
|
||||
let stderr = new LineSplitter({ readableObjectMode: true });
|
||||
let onDataOut = line => {
|
||||
@@ -259,8 +269,8 @@ function spawn(name, cmd, waitFor) {
|
||||
});
|
||||
}
|
||||
|
||||
async function spawnNode(name, cmd, waitFor) {
|
||||
return await spawn(name, `node --enable-source-maps ${cmd}`, waitFor);
|
||||
function spawnNode(name, cmd, waitFor, options) {
|
||||
return spawn(name, `node --enable-source-maps ${cmd}`, waitFor, options);
|
||||
}
|
||||
|
||||
before(async function() {
|
||||
@@ -388,6 +398,7 @@ module.exports = {
|
||||
TestControl,
|
||||
TestControlConnector,
|
||||
TestHostConnector,
|
||||
execController,
|
||||
execCtlProcess,
|
||||
slowTest,
|
||||
get,
|
||||
|
||||
Reference in new issue
Block a user