按规划继续工作
结论:将 INI 派生非法参数文件和刀具表文件名的拒绝验证扩展到真实 Chromium OPFS 与 LinuxCNC INI WASM 路径,并通过 host/WASM/browser 聚合验证。
This commit is contained in:
@@ -61,6 +61,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function verifyRejects(fixtureName, operation, expectedPattern) {
|
||||
try {
|
||||
await operation();
|
||||
} catch (error) {
|
||||
if (!expectedPattern.test(error.message)) {
|
||||
throw new Error(`${fixtureName}: unexpected error ${error.message}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new Error(`${fixtureName}: expected rejection`);
|
||||
}
|
||||
|
||||
try {
|
||||
const interp = await createLinuxCncInterpSdk({
|
||||
locateFile(path) {
|
||||
@@ -400,6 +412,52 @@
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
await saveMachineTextFiles("browser-invalid-param-file-session", {
|
||||
ini: [
|
||||
"[EMC]",
|
||||
"MACHINE = browser-invalid-param-file-session",
|
||||
"",
|
||||
"[RS274NGC]",
|
||||
"PARAMETER_FILE = ../escape.var",
|
||||
"",
|
||||
].join("\n"),
|
||||
});
|
||||
await verifyRejects(
|
||||
"opfs_reject_invalid_ini_parameter_file",
|
||||
() => loadMachineSessionFromOpfs(
|
||||
interp,
|
||||
"browser-invalid-param-file-session",
|
||||
{
|
||||
iniSdk: ini,
|
||||
iniWasmPath: "/work/browser-invalid-param-file-session.ini",
|
||||
},
|
||||
),
|
||||
/Invalid parameter filename/,
|
||||
);
|
||||
|
||||
await saveMachineTextFiles("browser-invalid-tool-file-session", {
|
||||
ini: [
|
||||
"[EMC]",
|
||||
"MACHINE = browser-invalid-tool-file-session",
|
||||
"",
|
||||
"[EMCIO]",
|
||||
"TOOL_TABLE = nested/tool.tbl",
|
||||
"",
|
||||
].join("\n"),
|
||||
});
|
||||
await verifyRejects(
|
||||
"opfs_reject_invalid_ini_tool_table",
|
||||
() => loadMachineSessionFromOpfs(
|
||||
interp,
|
||||
"browser-invalid-tool-file-session",
|
||||
{
|
||||
iniSdk: ini,
|
||||
iniWasmPath: "/work/browser-invalid-tool-file-session.ini",
|
||||
},
|
||||
),
|
||||
/Invalid tool table filename/,
|
||||
);
|
||||
|
||||
status.textContent = "browser_interp_smoke=ok";
|
||||
} catch (error) {
|
||||
status.textContent = `browser_interp_smoke=fail ${error.stack || error.message}`;
|
||||
|
||||
Reference in New Issue
Block a user