Guard browser OPFS default filename constants

This commit is contained in:
2026-06-14 01:16:39 +08:00
parent febab4c20e
commit 0f5d31b088
2 changed files with 61 additions and 10 deletions

View File

@@ -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 语义。

View File

@@ -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(