mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Merge pull request #496 from Hornwitser/fix-tests-on-windows
Fix tests on windows
This commit is contained in:
9 files changed
+24
-14
No files matched your search
@@ -87,7 +87,7 @@ export default class Controller {
|
||||
|
||||
logDirectory: string = "";
|
||||
clusterLogIndex: lib.LogIndex | null = null;
|
||||
clusterLogBuildInterval: NodeJS.Timer | null = null;
|
||||
clusterLogBuildInterval: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
constructor(
|
||||
clusterLogger: winston.Logger,
|
||||
|
||||
@@ -17,7 +17,7 @@ export interface WebSocketClusterio extends WebSocket {
|
||||
* @alias module:controller/src/WsServerConnector
|
||||
*/
|
||||
export default class WsServerConnector extends lib.WebSocketBaseConnector {
|
||||
_timeoutId: NodeJS.Timeout | null = null;
|
||||
_timeoutId: ReturnType<typeof setTimeout> | null = null;
|
||||
declare _socket: WebSocketClusterio | null;
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -255,7 +255,7 @@ interface ProxyStream {
|
||||
mime: string | null;
|
||||
filename: string | null;
|
||||
events: events.EventEmitter;
|
||||
timeout: NodeJS.Timeout;
|
||||
timeout: ReturnType<typeof setTimeout>;
|
||||
}
|
||||
|
||||
export async function createProxyStream(app: Application): Promise<ProxyStream> {
|
||||
|
||||
@@ -662,7 +662,11 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " ");
|
||||
// not something we want to have. For this reason the mods
|
||||
// are hard linked instead.
|
||||
} else {
|
||||
await fs.link(target, link);
|
||||
try {
|
||||
await fs.link(target, link);
|
||||
} catch (err) {
|
||||
this.logger.warn(`Failed to link mod ${modFile}.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export default class RateLimiter {
|
||||
action?: Function;
|
||||
|
||||
private _lastRun = 0;
|
||||
private _runTimeout?: NodeJS.Timeout;
|
||||
private _runTimeout?: ReturnType<typeof setTimeout>;
|
||||
|
||||
/**
|
||||
* Construct RateLimiter helper
|
||||
|
||||
@@ -37,7 +37,7 @@ export async function wait(duration: number) {
|
||||
* @param {*=} timeoutResult - Value to return if the operation timed out.
|
||||
*/
|
||||
export async function timeout<T>(promise: Promise<T>, time: number, timeoutResult: T) {
|
||||
let timer: NodeJS.Timer | undefined;
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
try {
|
||||
return await Promise.race([
|
||||
promise,
|
||||
|
||||
@@ -99,7 +99,7 @@ export abstract class WebSocketBaseConnector extends BaseConnector {
|
||||
_closing = false;
|
||||
_socket: WebSocket | null = null;
|
||||
_lastHeartbeat: number | null = null;
|
||||
_heartbeatId: NodeJS.Timer | null = null;
|
||||
_heartbeatId: ReturnType<typeof setInterval> | null = null;
|
||||
_heartbeatInterval: number | null = null;
|
||||
_lastReceivedSeq = undefined;
|
||||
_sendBuffer: (ReliableMessages)[] = [];
|
||||
@@ -287,7 +287,7 @@ export abstract class WebSocketBaseConnector extends BaseConnector {
|
||||
this.setClosing();
|
||||
this._sendInternal(new libData.MessageDisconnect("prepare"));
|
||||
|
||||
let timeout: NodeJS.Timeout | undefined;
|
||||
let timeout: ReturnType<typeof setTimeout> | undefined;
|
||||
let waitTimeout = new Promise(resolve => { timeout = setTimeout(resolve, 10000); }); // Make Configurable?
|
||||
try {
|
||||
await Promise.race([
|
||||
@@ -331,7 +331,7 @@ export abstract class WebSocketBaseConnector extends BaseConnector {
|
||||
* @extends module:lib.WebSocketBaseConnector
|
||||
*/
|
||||
export abstract class WebSocketClientConnector extends WebSocketBaseConnector {
|
||||
_reconnectId?: NodeJS.Timeout;
|
||||
_reconnectId?: ReturnType<typeof setTimeout>;
|
||||
_sessionToken: string | null = null;
|
||||
_sessionTimeout: number | null = null;
|
||||
_startedResuming: number | null = null;
|
||||
|
||||
@@ -788,9 +788,13 @@ describe("Integration of Clusterio", function() {
|
||||
it("should have triggered for the previous instance status updates", function() {
|
||||
slowTest(this);
|
||||
let statusesToCheck = new Set([
|
||||
"unassigned", "unknown", "stopped", "creating_save", "exporting_data",
|
||||
"unassigned", "stopped", "creating_save", "exporting_data",
|
||||
"starting", "running", "stopping", "deleted",
|
||||
]);
|
||||
// Windows does not see the unknown status because alt-host is not spawned.
|
||||
if (process.platform !== "win32") {
|
||||
statusesToCheck.add("unknown");
|
||||
}
|
||||
let statusesNotSeen = new Set(statusesToCheck);
|
||||
|
||||
for (let update of getControl().instanceUpdates) {
|
||||
|
||||
@@ -79,30 +79,32 @@ describe("lib/plugin_loader", function() {
|
||||
);
|
||||
});
|
||||
it("should throw if class is missing from entrypoint", async function() {
|
||||
const requirePath = path.resolve(missingClass);
|
||||
await assert.rejects(
|
||||
lib.loadControllerPluginClass({
|
||||
name: "test",
|
||||
controllerEntrypoint: "controller",
|
||||
requirePath: path.resolve(missingClass),
|
||||
requirePath,
|
||||
}),
|
||||
{
|
||||
message:
|
||||
`PluginError: Expected ${path.resolve(missingClass, "controller")} ` +
|
||||
`PluginError: Expected ${path.posix.join(requirePath, "controller")} ` +
|
||||
"to export a class named ControllerPlugin",
|
||||
}
|
||||
);
|
||||
});
|
||||
it("should throw if class is not a subclass of BaseControllerPlugin", async function() {
|
||||
const requirePath = path.resolve(wrongParentClass);
|
||||
await assert.rejects(
|
||||
lib.loadControllerPluginClass({
|
||||
name: "test",
|
||||
controllerEntrypoint: "controller",
|
||||
requirePath: path.resolve(wrongParentClass),
|
||||
requirePath,
|
||||
}),
|
||||
{
|
||||
message:
|
||||
"PluginError: Expected ControllerPlugin exported from " +
|
||||
`${path.resolve(wrongParentClass, "controller")} to be a subclass of BaseControllerPlugin`,
|
||||
`${path.posix.join(requirePath, "controller")} to be a subclass of BaseControllerPlugin`,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user