fix(macos): validate DMG layout values

This commit is contained in:
Vincent Koc
2026-06-21 15:44:54 +02:00
parent 5d1e649aea
commit b28e68e0ce
2 changed files with 76 additions and 0 deletions

View File

@@ -265,6 +265,42 @@ describe.runIf(process.platform === "darwin")("create-dmg ownership boundaries",
expect(readFileSync(tools.hdiutilLog, "utf8")).not.toContain("detach");
});
it("fails before image creation when Finder layout values are malformed", () => {
const app = makeValidApp();
const outputDir = mkdtempSync(path.join(tmpdir(), "openclaw-create-dmg-output-"));
tempDirs.push(outputDir);
const output = path.join(outputDir, "OpenClaw.dmg");
const tools = makeFakeDmgTools();
const result = runScript([app, output], {
...tools.env,
DMG_WINDOW_BOUNDS: "400 nope 900 420",
});
expect(result.status).toBe(1);
expect(result.stderr).toContain("DMG_WINDOW_BOUNDS must contain only integer values");
expect(existsSync(output)).toBe(false);
expect(existsSync(tools.hdiutilLog) ? readFileSync(tools.hdiutilLog, "utf8") : "").toBe("");
});
it("fails before image creation when Finder layout values span multiple lines", () => {
const app = makeValidApp();
const outputDir = mkdtempSync(path.join(tmpdir(), "openclaw-create-dmg-output-"));
tempDirs.push(outputDir);
const output = path.join(outputDir, "OpenClaw.dmg");
const tools = makeFakeDmgTools();
const result = runScript([app, output], {
...tools.env,
DMG_WINDOW_BOUNDS: "400 100 900 420\nnope",
});
expect(result.status).toBe(1);
expect(result.stderr).toContain("DMG_WINDOW_BOUNDS must be a single line");
expect(existsSync(output)).toBe(false);
expect(existsSync(tools.hdiutilLog) ? readFileSync(tools.hdiutilLog, "utf8") : "").toBe("");
});
it("preserves an existing output when verification fails", () => {
const app = makeValidApp();
const outputDir = mkdtempSync(path.join(tmpdir(), "openclaw-create-dmg-output-"));