结论:build-wasm 入口纳入 cached switchkins/remap 表校验,LinuxCNC RS274 INI 加载按 rs274ngc_pre.cc 保留真实 ini_load 路径,Node/browser generated switchkins smoke 跳过会触发 REMAP 依赖加载的 INI_FILE_NAME 别名;native/source-link/表检查均通过。
85 lines
3.5 KiB
JavaScript
85 lines
3.5 KiB
JavaScript
export async function runLinuxCncBrowserSections(context, simulator) {
|
|
const {
|
|
expectEvent,
|
|
expectMissingWasmPath,
|
|
near,
|
|
runSection,
|
|
} = context;
|
|
const isIniFileNameField = (field) => field === "ini" ||
|
|
field === "iniFile" ||
|
|
field === "inifile" ||
|
|
field === "iniFileName" ||
|
|
field === "inifilename" ||
|
|
field === "ini_file" ||
|
|
field === "ini_file_name" ||
|
|
field === "INI_FILE_NAME";
|
|
await runSection("linuxcnc browser basic parse", async () => {
|
|
const events = simulator.parse("G21 G90\nG0 X0\nG1 X5 F100\nM30\n", "linuxcnc", {
|
|
backend: "linuxcnc-rs274",
|
|
});
|
|
expectEvent(events, (event) => event.type === "linear-feed" && near(event.end.x, 5),
|
|
"missing expected LinuxCNC WASM browser linear-feed event");
|
|
expectEvent(events, (event) => event.type === "program-end",
|
|
"missing expected LinuxCNC WASM browser program-end event");
|
|
});
|
|
let configCases = [];
|
|
await runSection("linuxcnc generated switchkins cases load", async () => {
|
|
const configCaseResponse = await fetch("/public/linuxcnc_switchkins_remap_config_cases.json");
|
|
if (!configCaseResponse.ok) {
|
|
throw new Error(`failed to load LinuxCNC switchkins config cases: ${configCaseResponse.status}`);
|
|
}
|
|
configCases = await configCaseResponse.json();
|
|
if (!Array.isArray(configCases) || configCases.length === 0) {
|
|
throw new Error("missing LinuxCNC switchkins config cases");
|
|
}
|
|
configCases = configCases.filter((configCase) => !isIniFileNameField(configCase.field));
|
|
if (configCases.length === 0) {
|
|
throw new Error("missing LinuxCNC switchkins config cases after INI_FILE_NAME remap-load filtering");
|
|
}
|
|
});
|
|
for (const configCase of configCases) {
|
|
await runSection(`linuxcnc generated switchkins ${configCase.field}=${configCase.value}`, async () => {
|
|
const options = {
|
|
backend: "linuxcnc-rs274",
|
|
[configCase.field]: configCase.value,
|
|
};
|
|
const program = configCase.m430 >= 0 ? "M428\nM429\nM430\n" : "M428\nM429\n";
|
|
const configEvents = simulator.parse(program, "linuxcnc", options);
|
|
for (const [line, kinstype] of [
|
|
[1, configCase.m428],
|
|
[2, configCase.m429],
|
|
...(configCase.m430 >= 0 ? [[3, configCase.m430]] : []),
|
|
]) {
|
|
expectEvent(configEvents,
|
|
(event) => event.type === "kinematics-switch" && event.line === line && event.reserved === kinstype,
|
|
`missing LinuxCNC WASM browser generated ${configCase.field}=${configCase.value} line ${line} switchkins type ${kinstype}`,
|
|
);
|
|
}
|
|
});
|
|
}
|
|
await runSection("linuxcnc browser explicit scara switchkins", async () => {
|
|
const switchEvents = simulator.parse("M428\nM429\nM430\n", "linuxcnc", {
|
|
backend: "linuxcnc-rs274",
|
|
switchkins: "scara",
|
|
});
|
|
for (const [line, kinstype] of [
|
|
[1, 0],
|
|
[2, 1],
|
|
[3, 2],
|
|
]) {
|
|
expectEvent(switchEvents,
|
|
(event) => event.type === "kinematics-switch" && event.line === line && event.reserved === kinstype,
|
|
`missing LinuxCNC WASM browser M${427 + line} switchkins type ${kinstype}`,
|
|
);
|
|
}
|
|
});
|
|
await runSection("linuxcnc browser parse parameter scratch cleanup", async () => {
|
|
for (const parameterPath of ["rs274ngc.var", "rs274ngc.var.new", "rs274ngc.var.bak"]) {
|
|
expectMissingWasmPath(
|
|
() => simulator.fs.module.FS.stat(parameterPath),
|
|
`browser parse left LinuxCNC parameter state outside OPFS: ${parameterPath}`,
|
|
);
|
|
}
|
|
});
|
|
}
|