From 8e21290b2226de6fdc04dc2476d5eed32eafece0 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Thu, 12 Sep 2024 15:26:12 +0200 Subject: [PATCH] Enable skipped tests on Windows Use the stop host command to stop alt-host so that the tests that depend on it can also be run on Windows. --- test/host/server.js | 3 -- test/integration/clusterio.js | 52 +++++++++++------------------------ test/integration/server.js | 4 --- 3 files changed, 16 insertions(+), 43 deletions(-) diff --git a/test/host/server.js b/test/host/server.js index ea92a06c..d4d51b18 100644 --- a/test/host/server.js +++ b/test/host/server.js @@ -211,9 +211,6 @@ describe("host/server", function() { describe(".stop()", function() { it("should handle server quitting on its own during stop", async function() { - if (process.platform === "win32") { - this.skip(); - } server.hangTimeoutMs = 20; server._server = new events.EventEmitter(); server._server.kill = () => true; diff --git a/test/integration/clusterio.js b/test/integration/clusterio.js index cfedb438..c8225b84 100644 --- a/test/integration/clusterio.js +++ b/test/integration/clusterio.js @@ -48,8 +48,21 @@ async function startAltHost() { async function stopAltHost(hostProcess) { if (hostProcess && hostProcess.exitCode === null) { - hostProcess.kill("SIGINT"); - await events.once(hostProcess, "exit"); + const waitForExit = lib.timeout( + events.once(hostProcess, "exit"), + 10e3, + "timeout" + ).catch(() => {}); + try { + await execCtl("host stop 5"); + } catch (err) { + // Some tests cause the host to stop + } + if (await waitForExit === "timeout" && hostProcess.exitCode === null) { + // eslint-disable-next-line no-console + console.warn("Stopping alt-host failed. Killing."); + hostProcess.kill("SIGINT"); + } } } @@ -148,12 +161,6 @@ describe("Integration of Clusterio", function() { describe("clusteriohost", function() { describe("hostUpdateEventHandler()", function() { it("should trigger when a new host is added", async function() { - // On windows there's currently no way to automate graceful shutdown of the host - // process as CTRL+C is some weird terminal thing and SIGINT isn't a thing. - if (process.platform === "win32") { - this.skip(); - } - slowTest(this); getControl().hostUpdates = []; @@ -189,12 +196,6 @@ describe("Integration of Clusterio", function() { }); }); it("should download mods from controller", async function() { - // On windows there's currently no way to automate graceful shutdown of the host - // process as CTRL+C is some weird terminal thing and SIGINT isn't a thing. - if (process.platform === "win32") { - this.skip(); - } - slowTest(this); await runWithAltHost(async () => { const clusterioLib = path.join("temp", "test", "alt-mods", "clusterio_lib_0.1.2.zip"); @@ -206,12 +207,6 @@ describe("Integration of Clusterio", function() { }); }); it("should auto start instances with auto_start enabled", async function() { - // On windows there's currently no way to automate graceful shutdown of the host - // process as CTRL+C is some weird terminal thing and SIGINT isn't a thing. - if (process.platform === "win32") { - this.skip(); - } - slowTest(this); let hostProcess; @@ -310,12 +305,6 @@ describe("Integration of Clusterio", function() { }); describe("host revoke-token", async function() { it("should disconnect existing host", async function() { - // On windows there's currently no way to automate graceful shutdown of the host - // process as CTRL+C is some weird terminal thing and SIGINT isn't a thing. - if (process.platform === "win32") { - this.skip(); - } - slowTest(this); let sawDisconnected; await runWithAltHost(async () => { @@ -774,11 +763,6 @@ describe("Integration of Clusterio", function() { if (remote) { let hostProcess; before(async function() { - // On windows there's currently no way to automate graceful shutdown of the host - // process as CTRL+C is some weird terminal thing and SIGINT isn't a thing. - if (process.platform === "win32") { - this.skip(); - } slowTest(this); hostProcess = await startAltHost(); @@ -907,12 +891,8 @@ describe("Integration of Clusterio", function() { slowTest(this); let statusesToCheck = new Set([ "unassigned", "stopped", "creating_save", "exporting_data", - "starting", "running", "stopping", "deleted", + "starting", "running", "stopping", "deleted", "unknown", ]); - // 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) { diff --git a/test/integration/server.js b/test/integration/server.js index 02d088cf..aac8f0ba 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -219,10 +219,6 @@ describe("Integration of host/src/server", function() { describe(".start() termination detection", function() { it("should tell if Factorio got killed", async function() { - // This does not work on Windows - if (process.platform === "win32") { - this.skip(); - } slowTest(this); log(".start() for kill detection");