From 36fc2ac1db3e2a542be6a1d3c294c5a665c44fba Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Thu, 12 Sep 2024 19:03:22 +0200 Subject: [PATCH] Support nested factorio dirs in server test Source the factorio directory from the host config as with other tests and handle it pointing to a folder of Factorio installations. --- test/integration/server.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/integration/server.js b/test/integration/server.js index aac8f0ba..34890699 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -14,9 +14,25 @@ const { slowTest, factorioDir } = require("./index"); describe("Integration of host/src/server", function() { describe("_getVersion()", function() { it("should get a version from factorio's changelog.txt", async function() { + function checkVersion(version) { + if (!/^\d+\.\d+\.\d+$/.test(version)) { + assert.fail(`Detected version '${version}' does not followed the format x.y.z`); + } + } + let version = await _getVersion(path.join(factorioDir, "data", "changelog.txt")); - if (!/^\d+\.\d+\.\d+$/.test(version)) { - assert.fail(`Detected version '${version}' does not followed the format x.y.z`); + if (version !== null) { + checkVersion(version); + } else { + for (let entry of await fs.readdir(factorioDir, { withFileTypes: true })) { + if (!entry.isDirectory()) { + continue; + } + + checkVersion( + await _getVersion(path.join(factorioDir, entry.name, "data", "changelog.txt")) + ); + } } }); });