Guard fixture loop staging
This commit is contained in:
@@ -4336,6 +4336,14 @@
|
||||
return wasmPath;
|
||||
}
|
||||
|
||||
async function writeLocalErrorGcodeFixture(interp, fixtureName, wasmPath, expectedWasmPath) {
|
||||
if (wasmPath !== expectedWasmPath) {
|
||||
throw new Error(`browser_${fixtureName}_local_error_gcode_staging: path drift`);
|
||||
}
|
||||
interp.writeTextFile(wasmPath, await fetchText(`../fixtures/gcode_errors/${fixtureName}.ngc`));
|
||||
return wasmPath;
|
||||
}
|
||||
|
||||
async function loadSimMachineFiles(machineRel, iniFile, programFile = null) {
|
||||
const iniText = await fetchText(
|
||||
`../../vendor/linuxcnc/configs/sim/${machineRel}/${iniFile}`,
|
||||
@@ -5215,10 +5223,11 @@
|
||||
}
|
||||
|
||||
for (const errorFixtureName of INTERP_ERROR_FIXTURES) {
|
||||
const programPath = `/work/${errorFixtureName}-error.ngc`;
|
||||
interp.writeTextFile(
|
||||
programPath,
|
||||
await fetchText(`../fixtures/gcode_errors/${errorFixtureName}.ngc`),
|
||||
const programPath = await writeLocalErrorGcodeFixture(
|
||||
interp,
|
||||
errorFixtureName,
|
||||
`/work/${errorFixtureName}-error.ngc`,
|
||||
`/work/${errorFixtureName}-error.ngc`,
|
||||
);
|
||||
verifyExpectedFileError(
|
||||
`${errorFixtureName}_file`,
|
||||
@@ -5308,8 +5317,12 @@
|
||||
);
|
||||
|
||||
for (const fileFixtureName of INTERP_BROWSER_FILE_FIXTURES) {
|
||||
const programPath = `/work/${fileFixtureName}.ngc`;
|
||||
interp.writeTextFile(programPath, await fetchText(`../fixtures/gcode/${fileFixtureName}.ngc`));
|
||||
const programPath = await writeLocalGcodeFixture(
|
||||
interp,
|
||||
fileFixtureName,
|
||||
`/work/${fileFixtureName}.ngc`,
|
||||
`/work/${fileFixtureName}.ngc`,
|
||||
);
|
||||
verifyExpectedOutput(
|
||||
`${fileFixtureName}_file`,
|
||||
interp.runFile(programPath),
|
||||
|
||||
@@ -124,6 +124,15 @@ function writeLocalGcodeFixture(fixtureName, wasmPath, expectedWasmPath, targetI
|
||||
return wasmPath;
|
||||
}
|
||||
|
||||
function writeLocalErrorGcodeFixture(fixtureName, wasmPath, expectedWasmPath, targetInterp = interp) {
|
||||
assert.equal(wasmPath, expectedWasmPath, `${fixtureName} local error gcode staging path drift`);
|
||||
targetInterp.writeTextFile(
|
||||
wasmPath,
|
||||
readFileSync(resolve(rootDir, `tests/fixtures/gcode_errors/${fixtureName}.ngc`), "utf8"),
|
||||
);
|
||||
return wasmPath;
|
||||
}
|
||||
|
||||
function stageInterpIniContext(name, programFile = "test.ngc") {
|
||||
const sourceRootRel = `tests/interp/${name}`;
|
||||
const iniText = readFileSync(
|
||||
@@ -684,32 +693,30 @@ for (const fixtureName of INTERP_ERROR_FIXTURES) {
|
||||
}
|
||||
|
||||
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 programPath = writeLocalErrorGcodeFixture(
|
||||
fixtureName,
|
||||
`/work/${fixtureName}-error.ngc`,
|
||||
`/work/${fixtureName}-error.ngc`,
|
||||
);
|
||||
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(
|
||||
resolve(rootDir, `tests/fixtures/gcode/${fixtureName}.ngc`),
|
||||
"utf8",
|
||||
const programPath = writeLocalGcodeFixture(
|
||||
fixtureName,
|
||||
`/work/${fixtureName}.ngc`,
|
||||
`/work/${fixtureName}.ngc`,
|
||||
);
|
||||
const expectedEvents = readFileSync(
|
||||
resolve(rootDir, `tests/fixtures/canon/${fixtureName}.events`),
|
||||
"utf8",
|
||||
).trimEnd();
|
||||
|
||||
interp.writeTextFile(programPath, programText);
|
||||
verifyExpectedOutput(fixtureName, interp.runFile(programPath), expectedEvents);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user