Guard browser OPFS machine file readback helper

This commit is contained in:
2026-06-14 00:24:45 +08:00
parent caa6fd98c4
commit c35b8bba9e
2 changed files with 69 additions and 11 deletions

View File

@@ -4539,6 +4539,11 @@
verifyExpectedOutput(label, await loadTextFile(opfsPath), expectedText);
}
async function verifyOpfsMachineFileReadback(label, machineId, fileKey, expectedText) {
const machineFiles = await loadMachineTextFiles(machineId);
verifyExpectedOutput(label, machineFiles[fileKey], expectedText);
}
async function writeOpfsMachineFile(machineId, filename, text) {
const opfsPath = opfsMachineFilePath(machineId, filename);
await saveTextFile(opfsPath, text);
@@ -9237,10 +9242,10 @@
"parameter_5399=66.6",
].join("\n"),
);
const machineFiles = await loadMachineTextFiles(browserInterpMachineId);
verifyExpectedOutput(
await verifyOpfsMachineFileReadback(
"opfs_saved_parameter_text",
machineFiles.parameters,
browserInterpMachineId,
"parameters",
[
"5161\t12.340000",
"5162\t56.780000",
@@ -9281,10 +9286,10 @@
"tool_1.pocketno=7",
].join("\n"),
);
const savedMachineFiles = await loadMachineTextFiles(browserInterpMachineId);
verifyExpectedOutput(
await verifyOpfsMachineFileReadback(
"opfs_saved_tool_table_text",
savedMachineFiles.toolTable,
browserInterpMachineId,
"toolTable",
[
"T2",
"P7",
@@ -9391,12 +9396,10 @@
"tool_pocket_9.toolno=5",
].join("\n"),
);
const savedRandomMachineFiles = await loadMachineTextFiles(
browserRandomMachineId,
);
verifyExpectedOutput(
await verifyOpfsMachineFileReadback(
"opfs_saved_random_tool_table_text",
savedRandomMachineFiles.toolTable,
browserRandomMachineId,
"toolTable",
[
"T2",
"P7",