Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit c580f889c840ee1ec3f94a23093a2c52427d7c76
parent 2ef48072184301471ac7a91432b675b0fb1c4023
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 29 Oct 2026 00:15:57 -0400

umtool: modulesCli tests -- dry run, a take from the patch, the writer, a refused config

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Aumtool/lib/report/modulesCli.test.mjs | 89+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+), 0 deletions(-)

diff --git a/umtool/lib/report/modulesCli.test.mjs b/umtool/lib/report/modulesCli.test.mjs @@ -0,0 +1,89 @@ +// `umtool modules` and `umtool preset` (modulesCli.mjs) over a temp tree. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs"; +import os from "node:os"; +import path from "node:path"; + +import { modulesCommand, presetCommand } from "./modulesCli.mjs"; + +const clip = (id, start) => ({ type: "clip", id, channel: "c", video: "v", start, end: start + 3 }); + +function tree() { + const root = mkdtempSync(path.join(os.tmpdir(), "modules-cli-")); + const dir = path.join(root, "proj"); + mkdirSync(dir, { recursive: true }); + writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify({ + schemaVersion: 1, slug: "proj", title: "Proj", provenance: {}, + render: { width: 1920, height: 1080, fps: 30 }, timeline: [clip("a", 0), clip("b", 10)], + })); + writeFileSync(path.join(dir, "module-config.json"), JSON.stringify({ + preset: "plain-deck", + modules: { chapter: [{ atClip: "b", title: "Two" }], shell: { title: "x" } }, + })); + return { root, dir }; +} +const sink = () => { + const lines = []; + return { lines, log: (s) => lines.push(s), err: (s) => lines.push(`ERR ${s}`) }; +}; + +test("modules apply --dry-run says the patch and what has no home, and writes nothing", async () => { + const { root, dir } = tree(); + const before = readFileSync(path.join(dir, "video.manifest.json"), "utf8"); + const s = sink(); + assert.equal(await modulesCommand(["apply", dir, "--dry-run", "--json"], { reportsRoot: root, ...s }), 0, s.lines.join("\n")); + const r = JSON.parse(s.lines[0]); + assert.equal(r.patch.preset, "plain-deck"); + assert.deepEqual(r.patch.render.chrome.chapter, { list: [{ at: "b", title: "Two" }] }); + assert.ok(r.unmapped.some((u) => u.startsWith("modules.shell.title"))); + assert.equal(readFileSync(path.join(dir, "video.manifest.json"), "utf8"), before); +}); + +test("modules apply --take writes the take's patch and makes the take from it; the manifest untouched", async () => { + const { root, dir } = tree(); + const before = readFileSync(path.join(dir, "video.manifest.json"), "utf8"); + const s = sink(); + let got = null; + const take = async (args) => { got = args; return 0; }; + assert.equal(await modulesCommand(["apply", dir, "--take", "modules-1", "--at", "0", "--dur", "20", "--quick"], { reportsRoot: root, ...s, take }), 0, s.lines.join("\n")); + const patchFile = path.join(dir, "takes", "modules-1.modules-patch.json"); + assert.deepEqual(got.slice(1, 3), ["--id", "modules-1"]); + assert.ok(got.includes("--patch") && got[got.indexOf("--patch") + 1] === patchFile); + assert.ok(got.includes("--quick") && got.includes("--at")); + assert.equal(JSON.parse(readFileSync(patchFile, "utf8")).preset, "plain-deck"); + assert.equal(readFileSync(path.join(dir, "video.manifest.json"), "utf8"), before); +}); + +test("modules apply writes the manifest through the writer; preset apply none is refused while the chrome needs it", async () => { + const { root, dir } = tree(); + const s = sink(); + assert.equal(await modulesCommand(["apply", dir], { reportsRoot: root, ...s }), 0, s.lines.join("\n")); + const m = JSON.parse(readFileSync(path.join(dir, "video.manifest.json"), "utf8")); + assert.equal(m.preset, "plain-deck"); + assert.deepEqual(m.render.chrome, { chapter: { list: [{ at: "b", title: "Two" }] } }); + const t = sink(); + assert.equal(await presetCommand(["apply", "none", dir], { reportsRoot: root, ...t }), 1); + assert.match(t.lines.join("\n"), /render\.chrome\.engine/); + assert.equal(await presetCommand(["apply", "archive-catalog", dir], { reportsRoot: root, ...sink() }), 0); + assert.equal(JSON.parse(readFileSync(path.join(dir, "video.manifest.json"), "utf8")).preset, "archive-catalog"); +}); + +test("a config the cut could not build is refused, naming why", async () => { + const { root, dir } = tree(); + writeFileSync(path.join(dir, "module-config.json"), JSON.stringify({ modules: { chapter: [{ atClip: "b", title: "Two" }] } })); + const s = sink(); + // No preset and no deck: the chapter has no deck to stand in. + assert.equal(await modulesCommand(["apply", dir, "--dry-run"], { reportsRoot: root, ...s }), 1); + assert.match(s.lines.join("\n"), /refused/); +}); + +test("modules list and preset list", async () => { + const s = sink(); + assert.equal(await modulesCommand(["list", "--json"], s), 0); + const ids = JSON.parse(s.lines[0]).map((m) => m.id); + for (const id of ["pair", "chapter", "status", "finale", "intro"]) assert.ok(ids.includes(id), id); + const t = sink(); + assert.equal(await presetCommand(["list", "--json"], t), 0); + assert.deepEqual(JSON.parse(t.lines[0]).map((p) => p.name).sort(), ["archive-catalog", "huck-deck", "plain-deck"]); +});