拆分仿真测试程序目录
结论:将内置 G-code 测试程序从 simulation-app.js 移入 runtime/ui/simulation/programs/,建立一程序一模块的目录化程序库,并保持页面 API 与验证 gate 兼容。
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readdirSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import {
|
||||
DEFAULT_SIMULATION_PROGRAM,
|
||||
@@ -10,12 +13,24 @@ import {
|
||||
getSimulationTestPrograms,
|
||||
parseLinuxCncCanonicalMotion,
|
||||
} from "../../../runtime/ui/simulation/simulation-app.js";
|
||||
import {
|
||||
SIMULATION_TEST_PROGRAMS as directoryPrograms,
|
||||
} from "../../../runtime/ui/simulation/programs/index.js";
|
||||
|
||||
const programs = getSimulationTestPrograms();
|
||||
const root = resolve(dirname(fileURLToPath(import.meta.url)), "../../..");
|
||||
const programDir = resolve(root, "runtime/ui/simulation/programs");
|
||||
const programFiles = readdirSync(programDir).filter((file) => file.endsWith(".js") && file !== "index.js");
|
||||
|
||||
assert.equal(DEFAULT_SIMULATION_PROGRAM_ID, "square-linear");
|
||||
assert.equal(getSimulationTestProgram(DEFAULT_SIMULATION_PROGRAM_ID).text, DEFAULT_SIMULATION_PROGRAM);
|
||||
assert.ok(programs.length >= 5, "real simulation program inventory should cover multiple examples");
|
||||
assert.equal(programFiles.length, programs.length, "each simulation test program should live in its own programs/*.js file");
|
||||
assert.deepEqual(
|
||||
directoryPrograms.map(({ id }) => id),
|
||||
programs.map(({ id }) => id),
|
||||
"simulation-app should re-export the directory-backed program inventory",
|
||||
);
|
||||
|
||||
for (const program of programs) {
|
||||
assert.ok(program.id, "program id should be present");
|
||||
|
||||
Reference in New Issue
Block a user