Guard tool-table direct staging
This commit is contained in:
@@ -4459,6 +4459,19 @@
|
||||
return checkedPath;
|
||||
}
|
||||
|
||||
function generatedToolTablePath(wasmPath, expectedWasmPath) {
|
||||
if (wasmPath !== expectedWasmPath) {
|
||||
throw new Error(`browser_tool_table_fixture_${expectedWasmPath}: path drift`);
|
||||
}
|
||||
return wasmPath;
|
||||
}
|
||||
|
||||
function writeGeneratedToolTableFixture(interp, wasmPath, expectedWasmPath, text) {
|
||||
const checkedPath = generatedToolTablePath(wasmPath, expectedWasmPath);
|
||||
interp.writeTextFile(checkedPath, text);
|
||||
return checkedPath;
|
||||
}
|
||||
|
||||
async function loadSimMachineFiles(machineRel, iniFile, programFile = null) {
|
||||
const iniText = await fetchText(
|
||||
`../../vendor/linuxcnc/configs/sim/${machineRel}/${iniFile}`,
|
||||
@@ -8832,9 +8845,10 @@
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
const browserToolTablePath = "/work/browser-direct-tool.tbl";
|
||||
interp.writeTextFile(
|
||||
browserToolTablePath,
|
||||
const browserToolTablePath = writeGeneratedToolTableFixture(
|
||||
interp,
|
||||
"/work/browser-direct-tool.tbl",
|
||||
"/work/browser-direct-tool.tbl",
|
||||
[
|
||||
"T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser direct finish tool",
|
||||
"T5 P9 X1 Y2 Z3 ;browser direct rough tool",
|
||||
@@ -8888,9 +8902,10 @@
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
const browserRandomToolTablePath = "/work/browser-direct-random-tool.tbl";
|
||||
interp.writeTextFile(
|
||||
browserRandomToolTablePath,
|
||||
const browserRandomToolTablePath = writeGeneratedToolTableFixture(
|
||||
interp,
|
||||
"/work/browser-direct-random-tool.tbl",
|
||||
"/work/browser-direct-random-tool.tbl",
|
||||
[
|
||||
"T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser direct random finish tool",
|
||||
"T5 P9 X1 Y2 Z3 ;browser direct random rough tool",
|
||||
|
||||
@@ -219,6 +219,17 @@ function writeGeneratedParameterFixture(wasmPath, expectedWasmPath, text, target
|
||||
return checkedPath;
|
||||
}
|
||||
|
||||
function generatedToolTablePath(wasmPath, expectedWasmPath) {
|
||||
assert.equal(wasmPath, expectedWasmPath, `tool table fixture ${expectedWasmPath} staging path drift`);
|
||||
return wasmPath;
|
||||
}
|
||||
|
||||
function writeGeneratedToolTableFixture(wasmPath, expectedWasmPath, text, targetInterp = interp) {
|
||||
const checkedPath = generatedToolTablePath(wasmPath, expectedWasmPath);
|
||||
targetInterp.writeTextFile(checkedPath, text);
|
||||
return checkedPath;
|
||||
}
|
||||
|
||||
function stageInterpIniContext(name, programFile = "test.ngc") {
|
||||
const sourceRootRel = `tests/interp/${name}`;
|
||||
const iniText = readFileSync(
|
||||
@@ -3795,9 +3806,9 @@ assert.equal(savedParameterFile.includes("5399\t66.600000"), true);
|
||||
assert.equal(savedParameterFile.includes("_named_param"), false);
|
||||
assert.equal(backupParameterFile.includes("5161 10.5"), true);
|
||||
|
||||
const toolTablePath = "/work/tool.tbl";
|
||||
interp.writeTextFile(
|
||||
toolTablePath,
|
||||
const toolTablePath = writeGeneratedToolTableFixture(
|
||||
"/work/tool.tbl",
|
||||
"/work/tool.tbl",
|
||||
[
|
||||
"T2 P7 Z3.125 D1.5 I12 J34 Q4 ;finish tool",
|
||||
"T5 P9 X1 Y2 Z3 ;rough tool",
|
||||
@@ -3848,9 +3859,9 @@ assert.equal(savedToolTable.includes("T5"), true);
|
||||
assert.equal(savedToolTable.includes("P9"), true);
|
||||
assert.equal(savedToolTable.includes(";rough tool"), true);
|
||||
|
||||
const randomToolTablePath = "/work/random-tool.tbl";
|
||||
interp.writeTextFile(
|
||||
randomToolTablePath,
|
||||
const randomToolTablePath = writeGeneratedToolTableFixture(
|
||||
"/work/random-tool.tbl",
|
||||
"/work/random-tool.tbl",
|
||||
[
|
||||
"T2 P7 Z3.125 D1.5 I12 J34 Q4 ;random finish tool",
|
||||
"T5 P9 X1 Y2 Z3 ;random rough tool",
|
||||
|
||||
Reference in New Issue
Block a user