补充 Node WASM 文件路径错误覆盖
结论:Node WASM 解释器 smoke 现在通过 Interp::open/read/execute 文件路径 ABI 验证现有负向 G-code fixture 的 LinuxCNC 错误输出。
This commit is contained in:
@@ -34,6 +34,45 @@ function verifyExpectedOutput(fixtureName, output, expectedText) {
|
||||
}
|
||||
}
|
||||
|
||||
function verifyExpectedFileError(fixtureName, output, expectedText) {
|
||||
assert.equal(
|
||||
output.includes("file_open=0"),
|
||||
true,
|
||||
`${fixtureName}: file open`,
|
||||
);
|
||||
|
||||
const expectedLines = expectedText.split("\n").filter(Boolean);
|
||||
for (const expectedLine of expectedLines) {
|
||||
if (expectedLine.startsWith("absent=")) {
|
||||
const forbidden = expectedLine.slice("absent=".length);
|
||||
assert.equal(
|
||||
output.includes(forbidden),
|
||||
false,
|
||||
`${fixtureName}: unexpected ${forbidden}`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (expectedLine.startsWith("error_text=")) {
|
||||
const message = expectedLine.slice("error_text=".length);
|
||||
assert.equal(
|
||||
output.includes(`file_error_text=${message}`),
|
||||
true,
|
||||
`${fixtureName}: ${message}`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (expectedLine.startsWith("canon_event=")) {
|
||||
assert.equal(
|
||||
output.includes(expectedLine),
|
||||
true,
|
||||
`${fixtureName}: ${expectedLine}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const rootDir = resolve(__dirname, "../../..");
|
||||
@@ -92,6 +131,21 @@ for (const fixtureName of INTERP_ERROR_FIXTURES) {
|
||||
verifyExpectedOutput(fixtureName, interp.runProgram(programText), expectedOutput);
|
||||
}
|
||||
|
||||
for (const fixtureName of INTERP_ERROR_FIXTURES) {
|
||||
const programPath = `/work/${fixtureName}-error.ngc`;
|
||||
const programText = readFileSync(
|
||||
resolve(rootDir, `tests/fixtures/gcode_errors/${fixtureName}.ngc`),
|
||||
"utf8",
|
||||
);
|
||||
const expectedOutput = readFileSync(
|
||||
resolve(rootDir, `tests/fixtures/canon_errors/${fixtureName}.expected`),
|
||||
"utf8",
|
||||
).trimEnd();
|
||||
|
||||
interp.writeTextFile(programPath, programText);
|
||||
verifyExpectedFileError(fixtureName, interp.runFile(programPath), expectedOutput);
|
||||
}
|
||||
|
||||
for (const fixtureName of INTERP_FILE_FIXTURES) {
|
||||
const programPath = `/work/${fixtureName}.ngc`;
|
||||
const programText = readFileSync(
|
||||
|
||||
Reference in New Issue
Block a user