From 46807f05a50b051e7ea5396d38c0fb00474a3c52 Mon Sep 17 00:00:00 2001 From: cnc Date: Wed, 3 Jun 2026 15:31:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E6=8C=89=20align-linuxcnc=20?= =?UTF-8?q?=E7=BA=A6=E6=9D=9F=EF=BC=9A=E8=A1=A5=20OPFS=20=E9=95=9C?= =?UTF-8?q?=E5=83=8F=E8=B7=A8=E5=AE=9E=E4=BE=8B=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=EF=BC=8C=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...browser-wasm-smoke-opfs-mirror-sections.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/web/test-browser-wasm-smoke-opfs-mirror-sections.js b/web/test-browser-wasm-smoke-opfs-mirror-sections.js index d36a6be..a52a05c 100644 --- a/web/test-browser-wasm-smoke-opfs-mirror-sections.js +++ b/web/test-browser-wasm-smoke-opfs-mirror-sections.js @@ -1,8 +1,11 @@ export async function runBrowserOpfsMirrorSections(context, simulator) { const { + expectEvent, expectMissingWasmPath, expectText, + near, runSection, + withSmokeSimulator, } = context; 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"); }); + 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 () => { // LinuxCNC source basis: rs274ngc_pre.cc save_parameters() // links the current parameter file to filename + ".bak", then