增加解释器WASM命名参数夹具
结论:解释器核心WASM新增带INI文件边界的运行入口,并覆盖namedparam_semantics夹具,INI/HAL解析继续直接来自LinuxCNC解释器源码。
This commit is contained in:
@@ -27,6 +27,23 @@ function runProgram(mod, programText) {
|
||||
}
|
||||
}
|
||||
|
||||
function runProgramWithIni(mod, programText, iniPath) {
|
||||
const programPtr = allocCString(mod, programText);
|
||||
const iniPathPtr = allocCString(mod, iniPath);
|
||||
let resultPtr = 0;
|
||||
try {
|
||||
resultPtr = mod._lcinterp_run_program_with_ini(programPtr, iniPathPtr);
|
||||
assert.notEqual(resultPtr, 0);
|
||||
return mod.UTF8ToString(resultPtr);
|
||||
} finally {
|
||||
if (resultPtr) {
|
||||
mod._lcinterp_free_string(resultPtr);
|
||||
}
|
||||
mod._free(programPtr);
|
||||
mod._free(iniPathPtr);
|
||||
}
|
||||
}
|
||||
|
||||
function ensureDir(mod, path) {
|
||||
try {
|
||||
mod.FS.mkdir(path);
|
||||
@@ -114,6 +131,27 @@ for (const fixtureName of fixtureNames) {
|
||||
verifyExpectedOutput(fixtureName, runProgram(interp, programText), expectedEvents);
|
||||
}
|
||||
|
||||
ensureDir(interp, "/work");
|
||||
const namedParamIniPath = "/work/namedparams.ini";
|
||||
interp.FS.writeFile(
|
||||
namedParamIniPath,
|
||||
readFileSync(resolve(rootDir, "tests/fixtures/ini/namedparams.ini"), "utf8"),
|
||||
{ encoding: "utf8" },
|
||||
);
|
||||
const namedParamProgramText = readFileSync(
|
||||
resolve(rootDir, "tests/fixtures/gcode/namedparam_semantics.ngc"),
|
||||
"utf8",
|
||||
);
|
||||
const namedParamExpected = readFileSync(
|
||||
resolve(rootDir, "tests/fixtures/canon/namedparam_semantics.events"),
|
||||
"utf8",
|
||||
).trimEnd();
|
||||
verifyExpectedOutput(
|
||||
"namedparam_semantics",
|
||||
runProgramWithIni(interp, namedParamProgramText, namedParamIniPath),
|
||||
namedParamExpected,
|
||||
);
|
||||
|
||||
const errorFixtureNames = [
|
||||
"g1_zero_feed",
|
||||
"arc_radius_mismatch",
|
||||
@@ -140,7 +178,6 @@ const fileFixtureNames = [
|
||||
"oword_subroutine",
|
||||
];
|
||||
|
||||
ensureDir(interp, "/work");
|
||||
for (const fixtureName of fileFixtureNames) {
|
||||
const programPath = `/work/${fixtureName}.ngc`;
|
||||
const programText = readFileSync(
|
||||
|
||||
Reference in New Issue
Block a user