Guard browser machine text-store staging
This commit is contained in:
@@ -4478,6 +4478,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
function assertMachineTextStorePaths(label, paths, machineId) {
|
||||
const expectedPaths = {
|
||||
ini: `linuxcnc/machines/${machineId}/machine.ini`,
|
||||
toolTable: `linuxcnc/machines/${machineId}/tool.tbl`,
|
||||
parameters: `linuxcnc/machines/${machineId}/linuxcnc.var`,
|
||||
};
|
||||
for (const [name, expectedPath] of Object.entries(expectedPaths)) {
|
||||
if (paths[name] !== expectedPath) {
|
||||
throw new Error(`${label}: unexpected ${name} OPFS path ${paths[name]}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function generatedToolTablePath(wasmPath, expectedWasmPath) {
|
||||
if (wasmPath !== expectedWasmPath) {
|
||||
throw new Error(`browser_tool_table_fixture_${expectedWasmPath}: path drift`);
|
||||
@@ -8981,7 +8994,7 @@
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
await saveMachineTextFiles("browser-interp", {
|
||||
const browserInterpTextPaths = await saveMachineTextFiles("browser-interp", {
|
||||
ini: "[EMC]\nMACHINE = browser-interp\n",
|
||||
toolTable: "T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser finish tool\n",
|
||||
parameters: [
|
||||
@@ -8994,6 +9007,11 @@
|
||||
"",
|
||||
].join("\n"),
|
||||
});
|
||||
assertMachineTextStorePaths(
|
||||
"opfs_save_machine_text_files_staging",
|
||||
browserInterpTextPaths,
|
||||
"browser-interp",
|
||||
);
|
||||
const loadedSession = await loadMachineSessionFromOpfs(
|
||||
interp,
|
||||
"browser-interp",
|
||||
@@ -9137,7 +9155,7 @@
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
await saveMachineTextFiles("browser-random-toolchanger", {
|
||||
const browserRandomTextPaths = await saveMachineTextFiles("browser-random-toolchanger", {
|
||||
ini: [
|
||||
"[EMC]",
|
||||
"MACHINE = browser-random-toolchanger",
|
||||
@@ -9160,6 +9178,11 @@
|
||||
"",
|
||||
].join("\n"),
|
||||
});
|
||||
assertMachineTextStorePaths(
|
||||
"opfs_save_random_machine_text_files_staging",
|
||||
browserRandomTextPaths,
|
||||
"browser-random-toolchanger",
|
||||
);
|
||||
const loadedRandomSession = await loadMachineSessionFromOpfs(
|
||||
interp,
|
||||
"browser-random-toolchanger",
|
||||
@@ -9243,7 +9266,7 @@
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
await saveMachineTextFiles("browser-ini-file-session", {
|
||||
const browserIniFileTextPaths = await saveMachineTextFiles("browser-ini-file-session", {
|
||||
ini: [
|
||||
"[EMC]",
|
||||
"MACHINE = browser-ini-file-session",
|
||||
@@ -9256,6 +9279,11 @@
|
||||
"",
|
||||
].join("\n"),
|
||||
});
|
||||
assertMachineTextStorePaths(
|
||||
"opfs_save_ini_named_machine_text_files_staging",
|
||||
browserIniFileTextPaths,
|
||||
"browser-ini-file-session",
|
||||
);
|
||||
await saveTextFile(
|
||||
"linuxcnc/machines/browser-ini-file-session/browser-custom.var",
|
||||
[
|
||||
@@ -9410,7 +9438,7 @@
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
await saveMachineTextFiles("browser-ini-override-session", {
|
||||
const browserIniOverrideTextPaths = await saveMachineTextFiles("browser-ini-override-session", {
|
||||
ini: [
|
||||
"[EMC]",
|
||||
"MACHINE = browser-ini-override-session",
|
||||
@@ -9423,6 +9451,11 @@
|
||||
"",
|
||||
].join("\n"),
|
||||
});
|
||||
assertMachineTextStorePaths(
|
||||
"opfs_save_ini_override_machine_text_files_staging",
|
||||
browserIniOverrideTextPaths,
|
||||
"browser-ini-override-session",
|
||||
);
|
||||
await saveTextFile(
|
||||
"linuxcnc/machines/browser-ini-override-session/browser-explicit.var",
|
||||
[
|
||||
@@ -9579,7 +9612,7 @@
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
await saveMachineTextFiles("browser-invalid-param-file-session", {
|
||||
const invalidParamFileTextPaths = await saveMachineTextFiles("browser-invalid-param-file-session", {
|
||||
ini: [
|
||||
"[EMC]",
|
||||
"MACHINE = browser-invalid-param-file-session",
|
||||
@@ -9589,6 +9622,11 @@
|
||||
"",
|
||||
].join("\n"),
|
||||
});
|
||||
assertMachineTextStorePaths(
|
||||
"opfs_save_invalid_param_machine_text_files_staging",
|
||||
invalidParamFileTextPaths,
|
||||
"browser-invalid-param-file-session",
|
||||
);
|
||||
const invalidParamFileSessionOptions = {
|
||||
iniSdk: ini,
|
||||
iniWasmPath: "/work/browser-invalid-param-file-session.ini",
|
||||
@@ -9612,7 +9650,7 @@
|
||||
/Invalid parameter filename/,
|
||||
);
|
||||
|
||||
await saveMachineTextFiles("browser-invalid-tool-file-session", {
|
||||
const invalidToolFileTextPaths = await saveMachineTextFiles("browser-invalid-tool-file-session", {
|
||||
ini: [
|
||||
"[EMC]",
|
||||
"MACHINE = browser-invalid-tool-file-session",
|
||||
@@ -9622,6 +9660,11 @@
|
||||
"",
|
||||
].join("\n"),
|
||||
});
|
||||
assertMachineTextStorePaths(
|
||||
"opfs_save_invalid_tool_machine_text_files_staging",
|
||||
invalidToolFileTextPaths,
|
||||
"browser-invalid-tool-file-session",
|
||||
);
|
||||
const invalidToolFileSessionOptions = {
|
||||
iniSdk: ini,
|
||||
iniWasmPath: "/work/browser-invalid-tool-file-session.ini",
|
||||
|
||||
Reference in New Issue
Block a user