Guard local gcode fixture staging

This commit is contained in:
2026-06-13 14:48:25 +08:00
parent 0132cb34ee
commit dbf55e8230
3 changed files with 119 additions and 40 deletions

View File

@@ -106,6 +106,15 @@ function writeVendorTextFile(sourcePath, wasmPath, targetInterp = interp) {
targetInterp.writeTextFile(wasmPath, readFileSync(sourcePath, "utf8"));
}
function writeLocalGcodeFixture(fixtureName, wasmPath, expectedWasmPath, targetInterp = interp) {
assert.equal(wasmPath, expectedWasmPath, `${fixtureName} local gcode staging path drift`);
targetInterp.writeTextFile(
wasmPath,
readFileSync(resolve(rootDir, `tests/fixtures/gcode/${fixtureName}.ngc`), "utf8"),
);
return wasmPath;
}
function stageInterpIniContext(name, programFile = "test.ngc") {
const sourceRootRel = `tests/interp/${name}`;
const iniText = readFileSync(
@@ -767,13 +776,10 @@ verifyExpectedOutput(
].join("\n"),
);
const coordinateOffsetsFilePath = `/work/${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}.ngc`;
interp.writeTextFile(
coordinateOffsetsFilePath,
readFileSync(
resolve(rootDir, `tests/fixtures/gcode/${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}.ngc`),
"utf8",
),
const coordinateOffsetsFilePath = writeLocalGcodeFixture(
INTERP_COORDINATE_OFFSETS_FILE_FIXTURE,
`/work/${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}.ngc`,
`/work/${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}.ngc`,
);
verifyExpectedOutput(
`${INTERP_COORDINATE_OFFSETS_FILE_FIXTURE}_file`,
@@ -787,13 +793,10 @@ verifyExpectedOutput(
).trimEnd(),
);
const positionParamsFilePath = "/work/position_params.ngc";
interp.writeTextFile(
positionParamsFilePath,
readFileSync(
resolve(rootDir, `tests/fixtures/gcode/${INTERP_POSITION_PARAMS_FILE_FIXTURE}.ngc`),
"utf8",
),
const positionParamsFilePath = writeLocalGcodeFixture(
INTERP_POSITION_PARAMS_FILE_FIXTURE,
`/work/${INTERP_POSITION_PARAMS_FILE_FIXTURE}.ngc`,
`/work/${INTERP_POSITION_PARAMS_FILE_FIXTURE}.ngc`,
);
verifyExpectedOutput(
`${INTERP_POSITION_PARAMS_FILE_FIXTURE}_file`,