继续按 align-linuxcnc 约束:补 OPFS 镜像跨实例浏览器验证,测试通过

This commit is contained in:
cnc
2026-06-03 15:31:05 +08:00
parent 77f9754833
commit 46807f05a5

View File

@@ -1,8 +1,11 @@
export async function runBrowserOpfsMirrorSections(context, simulator) { export async function runBrowserOpfsMirrorSections(context, simulator) {
const { const {
expectEvent,
expectMissingWasmPath, expectMissingWasmPath,
expectText, expectText,
near,
runSection, runSection,
withSmokeSimulator,
} = context; } = context;
await runSection("opfs wasm mirror persist file", async () => { await runSection("opfs wasm mirror persist file", async () => {
@@ -20,6 +23,25 @@ export async function runBrowserOpfsMirrorSections(context, simulator) {
"persisted WASM filesystem file was not readable from OPFS"); "persisted WASM filesystem file was not readable from OPFS");
}); });
await runSection("opfs persisted wasm mirror parse in new instance", async () => {
await withSmokeSimulator(async (restoredMirrorSimulator) => {
// LinuxCNC source basis: rs274ngc_pre.cc read_text() reads
// program blocks after the OPFS file is mirrored into the WASM FS.
const persistedProgram = new TextDecoder().decode(
await restoredMirrorSimulator.fs.opfs.readFile("programs/browser-persisted.ngc"),
);
expectText(persistedProgram, "G21 G90\nG0 X2\n",
"persisted WASM mirror file was not restored from OPFS in a new instance");
const persistedEvents = await restoredMirrorSimulator.parseFile(
"programs/browser-persisted.ngc",
"linuxcnc",
{ backend: "linuxcnc-rs274" },
);
expectEvent(persistedEvents, (event) => event.type === "rapid" && near(event.end.x, 2),
"persisted WASM mirror file was not parsed through LinuxCNC in a new instance");
});
});
await runSection("opfs copy and move mirror files", async () => { await runSection("opfs copy and move mirror files", async () => {
// LinuxCNC source basis: rs274ngc_pre.cc save_parameters() // LinuxCNC source basis: rs274ngc_pre.cc save_parameters()
// links the current parameter file to filename + ".bak", then // links the current parameter file to filename + ".bak", then