factorio-test-cli 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/cli-config.js +1 -0
- package/config/loader.js +1 -0
- package/mod-setup.js +12 -9
- package/package.json +1 -1
- package/run.js +20 -2
package/config/cli-config.js
CHANGED
|
@@ -131,6 +131,7 @@ export function registerAllCliOptions(command) {
|
|
|
131
131
|
command.option("-c --config <path>", "Path to config file (default: factorio-test.json, or 'factorio-test' key in package.json)");
|
|
132
132
|
command.option("-g --graphics", "Launch Factorio with graphics (interactive mode) instead of headless");
|
|
133
133
|
command.option("-w --watch", "Watch for file changes and rerun tests");
|
|
134
|
+
command.option("--no-auto-start", "Configure tests but do not auto-start them (requires --graphics)");
|
|
134
135
|
addOption(command, f.modPath.cli);
|
|
135
136
|
addOption(command, f.modName.cli);
|
|
136
137
|
addOption(command, f.factorioPath.cli);
|
package/config/loader.js
CHANGED
|
@@ -58,6 +58,7 @@ export function resolveConfig({ cliOptions, patterns }) {
|
|
|
58
58
|
return {
|
|
59
59
|
graphics: cliOptions.graphics,
|
|
60
60
|
watch: cliOptions.watch,
|
|
61
|
+
noAutoStart: cliOptions.autoStart === false ? true : undefined,
|
|
61
62
|
modPath: baseConfig.modPath,
|
|
62
63
|
modName: baseConfig.modName,
|
|
63
64
|
factorioPath: baseConfig.factorioPath,
|
package/mod-setup.js
CHANGED
|
@@ -154,17 +154,20 @@ locale=
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
export async function
|
|
157
|
+
export async function ensureModSettingsDat(factorioPath, dataDir, modsDir, verbose) {
|
|
158
158
|
const settingsDat = path.join(modsDir, "mod-settings.dat");
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
159
|
+
if (fs.existsSync(settingsDat))
|
|
160
|
+
return;
|
|
161
|
+
if (verbose)
|
|
162
|
+
console.log("Creating mod-settings.dat file by running factorio");
|
|
163
|
+
const dummySaveFile = path.join(dataDir, "____dummy_save_file.zip");
|
|
164
|
+
await runProcess(false, factorioPath, "--create", dummySaveFile, "--mod-directory", modsDir, "-c", path.join(dataDir, "config.ini"));
|
|
165
|
+
if (fs.existsSync(dummySaveFile)) {
|
|
166
|
+
await fsp.rm(dummySaveFile);
|
|
167
167
|
}
|
|
168
|
+
}
|
|
169
|
+
export async function setSettingsForAutorun(factorioPath, dataDir, modsDir, modToTest, mode, options) {
|
|
170
|
+
await ensureModSettingsDat(factorioPath, dataDir, modsDir, options?.verbose);
|
|
168
171
|
if (options?.verbose)
|
|
169
172
|
console.log("Setting autorun settings");
|
|
170
173
|
const autoStartConfig = JSON.stringify({
|
package/package.json
CHANGED
package/run.js
CHANGED
|
@@ -8,7 +8,7 @@ import { registerAllCliOptions, resolveConfig } from "./config/index.js";
|
|
|
8
8
|
import { autoDetectFactorioPath } from "./factorio-process.js";
|
|
9
9
|
import { getHeadlessSavePath, runFactorioTestsGraphics, runFactorioTestsHeadless, } from "./factorio-process.js";
|
|
10
10
|
import { watchDirectory, watchFile } from "./file-watcher.js";
|
|
11
|
-
import { configureModToTest, ensureConfigIni, installFactorioTest, installModDependencies, installMods, parseModRequirement, resetAutorunSettings, resolveModWatchTarget, setSettingsForAutorun, } from "./mod-setup.js";
|
|
11
|
+
import { configureModToTest, ensureConfigIni, ensureModSettingsDat, installFactorioTest, installModDependencies, installMods, parseModRequirement, resetAutorunSettings, resolveModWatchTarget, setSettingsForAutorun, } from "./mod-setup.js";
|
|
12
12
|
import { runScript, setVerbose } from "./process-utils.js";
|
|
13
13
|
import { OutputFormatter } from "./test-output.js";
|
|
14
14
|
import { readPreviousFailedTests, writeResultsFile } from "./test-results.js";
|
|
@@ -47,6 +47,9 @@ async function setupTestRun(patterns, cliOptions) {
|
|
|
47
47
|
if (config.modPath === undefined && config.modName === undefined) {
|
|
48
48
|
throw new CliError("One of --mod-path or --mod-name must be specified.");
|
|
49
49
|
}
|
|
50
|
+
if (config.noAutoStart && !config.graphics) {
|
|
51
|
+
throw new CliError("--no-auto-start requires --graphics.");
|
|
52
|
+
}
|
|
50
53
|
const factorioPath = config.factorioPath ?? autoDetectFactorioPath();
|
|
51
54
|
const dataDir = config.dataDirectory;
|
|
52
55
|
const modsDir = path.join(dataDir, "mods");
|
|
@@ -191,9 +194,24 @@ async function runHeadlessWatchMode(ctx) {
|
|
|
191
194
|
});
|
|
192
195
|
return new Promise(() => { });
|
|
193
196
|
}
|
|
197
|
+
async function launchWithoutAutoStart(ctx) {
|
|
198
|
+
const { config, factorioPath, dataDir, modsDir, modToTest, savePath, factorioArgs } = ctx;
|
|
199
|
+
await ensureModSettingsDat(factorioPath, dataDir, modsDir, config.verbose);
|
|
200
|
+
await runScript("fmtk", "settings", "set", "runtime-global", "factorio-test-mod-to-test", modToTest, "--modsPath", modsDir);
|
|
201
|
+
if (Object.keys(config.testConfig).length > 0) {
|
|
202
|
+
await runScript("fmtk", "settings", "set", "runtime-global", "factorio-test-config", JSON.stringify(config.testConfig), "--modsPath", modsDir);
|
|
203
|
+
}
|
|
204
|
+
await runFactorioTestsGraphics(factorioPath, dataDir, savePath, factorioArgs, {
|
|
205
|
+
verbose: config.verbose,
|
|
206
|
+
quiet: config.quiet,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
194
209
|
async function runTests(patterns, cliOptions) {
|
|
195
210
|
const ctx = await setupTestRun(patterns, cliOptions);
|
|
196
|
-
if (ctx.config.
|
|
211
|
+
if (ctx.config.noAutoStart) {
|
|
212
|
+
await launchWithoutAutoStart(ctx);
|
|
213
|
+
}
|
|
214
|
+
else if (ctx.config.watch && ctx.config.graphics) {
|
|
197
215
|
await runGraphicsWatchMode(ctx);
|
|
198
216
|
}
|
|
199
217
|
else if (ctx.config.watch) {
|