[14][12] Kaputte Projekte: keine Abfrage wirft mehr, validate warnt vor hängenden Verweisen
Kern fällt bei hängenden Wandtypen/Bauteilen/Schraffuren/Linienstilen/Deckentypen auf Vorgaben zurück (Plan, Schnitt, Ansicht, 3D, IFC, Mesh); typisierte Sicht tolerant (model/lenient.rs: nur der Wert, der nicht passt, fällt auf die Vorgabe); Mesh-Export verwirft gebrochene Indizes/NaN-Ecken; projectWarnings (project_refs.rs) für dossier-cli/MCP validate. Fuzz-Test src/core/robustness.test.ts.
This commit is contained in:
29 files changed
+1323
-271
No files matched your search
@@ -38,6 +38,20 @@ describe("dossier-cli", () => {
|
||||
expect(JSON.parse(readFileSync(out, "utf8")).formatVersion).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it("validate meldet hängende Verweise als Warnung, Plan rechnet trotzdem", async () => {
|
||||
const broken = join(dir, "haengend.obp");
|
||||
const p = { ...sampleProject, walls: sampleProject.walls.map((w, i) => (i === 0 ? { ...w, wallTypeId: "nope" } : w)) };
|
||||
writeFileSync(broken, serializeProject(p));
|
||||
const err = vi.spyOn(process.stderr, "write").mockImplementation(() => true);
|
||||
try {
|
||||
expect(await run([broken, "validate"])).toBe(0);
|
||||
expect(err.mock.calls.map((c) => String(c[0])).join("")).toContain(`Warnung: Wand „${sampleProject.walls[0].id}": Wandtyp „nope" fehlt.`);
|
||||
} finally {
|
||||
err.mockRestore();
|
||||
}
|
||||
expect(await run([broken, "plan", "--out", join(dir, "haengend.svg")])).toBe(0);
|
||||
});
|
||||
|
||||
it("Plan als SVG", async () => {
|
||||
const out = join(dir, "eg.svg");
|
||||
expect(await call("plan", "--out", out)).toBe(0);
|
||||
|
||||
+5
-1
@@ -110,6 +110,7 @@ import {
|
||||
setWasmBytesProvider,
|
||||
initCore,
|
||||
validateProject,
|
||||
projectWarnings,
|
||||
sampleProject,
|
||||
} from "../core";
|
||||
import type { CoreOp, Project } from "../core";
|
||||
@@ -556,11 +557,14 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
}
|
||||
case "validate": {
|
||||
const problems = validateProject(project);
|
||||
// Hängende Verweise u. Ä.: das Projekt lässt sich rechnen (Vorgaben), aber es soll auffallen.
|
||||
const warnings = projectWarnings(project);
|
||||
if (warnings.length) process.stderr.write(warnings.map((w) => `Warnung: ${w}`).join("\n") + "\n");
|
||||
if (problems.length) {
|
||||
process.stderr.write(problems.join("\n") + "\n");
|
||||
return 1;
|
||||
}
|
||||
process.stdout.write("ok\n");
|
||||
process.stdout.write(warnings.length ? `ok (${warnings.length} Warnung${warnings.length === 1 ? "" : "en"})\n` : "ok\n");
|
||||
return 0;
|
||||
}
|
||||
case "migrate":
|
||||
|
||||
+3
-1
@@ -16,6 +16,7 @@ import {
|
||||
serializeProject,
|
||||
validateOps,
|
||||
validateProject,
|
||||
projectWarnings,
|
||||
} from "../core";
|
||||
import type { CoreOp, Project } from "../core";
|
||||
|
||||
@@ -124,7 +125,8 @@ export async function callTool(file: string, name: string, args: Record<string,
|
||||
}
|
||||
case "validate": {
|
||||
const problems = validateProject(project);
|
||||
return text(problems.length ? problems.join("\n") : "ok", problems.length > 0);
|
||||
const warnings = projectWarnings(project).map((w) => `Warnung: ${w}`);
|
||||
return text([...problems, ...warnings].join("\n") || "ok", problems.length > 0);
|
||||
}
|
||||
default:
|
||||
return text(`unbekanntes Werkzeug: ${name}`, true);
|
||||
|
||||
Reference in new issue
Block a user