From 0f5d31b0887c14a5894194ca1d9d35a4fc0afe4f Mon Sep 17 00:00:00 2001 From: wangdequan Date: Sun, 14 Jun 2026 01:16:39 +0800 Subject: [PATCH] Guard browser OPFS default filename constants --- text8.txt | 47 +++++++++++++++++++++++ wasm-port/tests/browser/interp_smoke.html | 24 +++++++----- 2 files changed, 61 insertions(+), 10 deletions(-) diff --git a/text8.txt b/text8.txt index 196fd11..0cd77e7 100644 --- a/text8.txt +++ b/text8.txt @@ -564,3 +564,50 @@ host_wasm_opfs_browser_smokes=ok `machine.ini`、`linuxcnc.var`、`tool.tbl` 是否值得抽成局部常量,只限 `interp_smoke.html` test glue;如果收益不明显,转向其它 browser staging path literal guard。 + +十四、2026-06-14 继续执行记录:browser OPFS default filename constants guard + +本轮按上一条下一步建议扫描 OPFS default filename 重复形态,确认收益明确后继续在 +`wasm-port/tests/browser/interp_smoke.html` 内做小范围 test glue 收敛。 + +完成内容: + +- 新增 `OPFS_DEFAULT_INI_FILENAME`、`OPFS_DEFAULT_PARAMETER_FILENAME`、 + `OPFS_DEFAULT_TOOL_TABLE_FILENAME` 三个局部常量; +- 将默认 machine file path helper、default session staging helper、invalid INI + path guard、default save staging 调用改为复用这些常量; +- custom fixture filename 仍保持在测试输入处外显; +- 未改变 OPFS bridge behavior、file-service、path-model、SDK planner、interpreter、 + INI、tool、parameter 或 LinuxCNC-owned runtime semantics。 + +验证已通过: + +```bash +git diff --check +wasm-port/tools/verify_vendor_sync.sh +wasm-port/tools/verify_no_standalone_cnc_semantics.sh +SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_interp_wasm.sh +SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_sim_configs_inventory_wasm.sh +SKIP_INI_BUILD=1 SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_interp_browser.sh +wasm-port/tests/host/verify_host_smokes.sh +``` + +关键输出: + +```text +vendor sync up to date +standalone CNC semantics guard complete +interp_wasm_node_smoke=ok +sim_configs_wasm_node_inventory_executed=28 +sim_configs_wasm_node_inventory_passed=28 +sim_configs_wasm_node_inventory_skipped=131 +sim_configs_wasm_node_inventory_unexpected_fail=0 +browser_interp_smoke=ok +host_wasm_opfs_browser_smokes=ok +``` + +下一步建议: + +转向其它 browser staging path literal guard。优先扫描 `interp_smoke.html` 中 +`/work/browser-*` WASM path 常量是否还有成组重复可收敛;只做测试胶水 helper 或 +常量,不改变 staging path 模型、OPFS bridge 或 LinuxCNC 语义。 diff --git a/wasm-port/tests/browser/interp_smoke.html b/wasm-port/tests/browser/interp_smoke.html index f9f8241..f9c49e1 100644 --- a/wasm-port/tests/browser/interp_smoke.html +++ b/wasm-port/tests/browser/interp_smoke.html @@ -4478,11 +4478,15 @@ } } + const OPFS_DEFAULT_INI_FILENAME = "machine.ini"; + const OPFS_DEFAULT_PARAMETER_FILENAME = "linuxcnc.var"; + const OPFS_DEFAULT_TOOL_TABLE_FILENAME = "tool.tbl"; + function assertMachineTextStorePaths(label, paths, machineId) { const expectedPaths = { - ini: opfsMachineFilePath(machineId, "machine.ini"), - toolTable: opfsMachineFilePath(machineId, "tool.tbl"), - parameters: opfsMachineFilePath(machineId, "linuxcnc.var"), + ini: opfsMachineFilePath(machineId, OPFS_DEFAULT_INI_FILENAME), + toolTable: opfsMachineFilePath(machineId, OPFS_DEFAULT_TOOL_TABLE_FILENAME), + parameters: opfsMachineFilePath(machineId, OPFS_DEFAULT_PARAMETER_FILENAME), }; for (const [name, expectedPath] of Object.entries(expectedPaths)) { if (paths[name] !== expectedPath) { @@ -4591,9 +4595,9 @@ throw new Error(`${label}: unexpected machine id ${session.machineId}`); } const expectedOpfsPaths = { - ini: opfsMachineFilePath(machineId, "machine.ini"), - parameters: opfsMachineFilePath(machineId, "linuxcnc.var"), - toolTable: opfsMachineFilePath(machineId, "tool.tbl"), + ini: opfsMachineFilePath(machineId, OPFS_DEFAULT_INI_FILENAME), + parameters: opfsMachineFilePath(machineId, OPFS_DEFAULT_PARAMETER_FILENAME), + toolTable: opfsMachineFilePath(machineId, OPFS_DEFAULT_TOOL_TABLE_FILENAME), ...(expectedPaths.opfs ?? {}), }; assertOpfsIniStaging( @@ -4626,7 +4630,7 @@ iniSdk, iniWasmPath: `/work/${machineId}.ini`, }; - const expectedIniOpfsPath = opfsMachineFilePath(machineId, "machine.ini"); + const expectedIniOpfsPath = opfsMachineFilePath(machineId, OPFS_DEFAULT_INI_FILENAME); assertOpfsIniStaging( `${label}_ini_staging`, { @@ -9254,7 +9258,7 @@ "opfs_save_parameters_staging", savedParameters, browserInterpMachineId, - "linuxcnc.var", + OPFS_DEFAULT_PARAMETER_FILENAME, browserInterpParameterWasmPath, ); verifyOpfsSaveResult( @@ -9300,7 +9304,7 @@ "opfs_save_tool_table_staging", savedToolTable, browserInterpMachineId, - "tool.tbl", + OPFS_DEFAULT_TOOL_TABLE_FILENAME, browserInterpToolTableWasmPath, ); verifyOpfsSaveResult( @@ -9410,7 +9414,7 @@ "opfs_save_random_tool_table_staging", savedRandomToolTable, browserRandomMachineId, - "tool.tbl", + OPFS_DEFAULT_TOOL_TABLE_FILENAME, browserRandomToolTableWasmPath, ); verifyOpfsSaveResult(