Guard restore-parameter negative staging

This commit is contained in:
2026-06-13 15:54:56 +08:00
parent 24a8f92fb0
commit bfb5655f28
3 changed files with 116 additions and 10 deletions

View File

@@ -4446,6 +4446,19 @@
return { disabledIniPath, iniPath, parameterPath, programPath };
}
function generatedParameterPath(wasmPath, expectedWasmPath) {
if (wasmPath !== expectedWasmPath) {
throw new Error(`browser_parameter_fixture_${expectedWasmPath}_staging: path drift`);
}
return wasmPath;
}
function writeGeneratedParameterFixture(interp, wasmPath, expectedWasmPath, text) {
const checkedPath = generatedParameterPath(wasmPath, expectedWasmPath);
interp.writeTextFile(checkedPath, text);
return checkedPath;
}
async function loadSimMachineFiles(machineRel, iniFile, programFile = null) {
const iniText = await fetchText(
`../../vendor/linuxcnc/configs/sim/${machineRel}/${iniFile}`,
@@ -8718,11 +8731,17 @@
verifyExpectedOutput(
"restore_parameters_missing_file",
interp.restoreParameters("/work/browser-missing.var"),
interp.restoreParameters(
generatedParameterPath("/work/browser-missing.var", "/work/browser-missing.var"),
),
"restore_parameters=0",
);
const outOfOrderParameterFilePath = "/work/browser-out-of-order.var";
interp.writeTextFile(outOfOrderParameterFilePath, "5220 1\n5161 2\n");
const outOfOrderParameterFilePath = writeGeneratedParameterFixture(
interp,
"/work/browser-out-of-order.var",
"/work/browser-out-of-order.var",
"5220 1\n5161 2\n",
);
verifyExpectedOutput(
"restore_parameters_out_of_order",
interp.restoreParameters(outOfOrderParameterFilePath),
@@ -8732,8 +8751,12 @@
].join("\n"),
);
const missingRequiredParameterFilePath = "/work/browser-missing-required.var";
interp.writeTextFile(missingRequiredParameterFilePath, "5161 3.5\n5220 1\n");
const missingRequiredParameterFilePath = writeGeneratedParameterFixture(
interp,
"/work/browser-missing-required.var",
"/work/browser-missing-required.var",
"5161 3.5\n5220 1\n",
);
verifyExpectedOutput(
"restore_parameters_missing_required",
interp.restoreParameters(missingRequiredParameterFilePath),