Files
JIANT/web/editor_layout_test.mjs
T
Claude dc74b4dbe4 Editor: the SOUND page's modules again on V10.8.7x (G_COUNT 77), not the plain list; appended parameters tolerated; a test in the site deploy
A user (via JIANT Studio): "the sound editor used to show modules, for a few
updates now it is a vertical list". knownLayout knew G_COUNT up to 73; the
firmware has 77 since the OTT / GATE globals, so the editor fell back to the
plain list. Now any G_COUNT from 73 up and any P_COUNT from 123 up with the
engine block last (P_E0 = P_COUNT - 8) is known: the firmware appends, the
ids the layout names stay. web/editor_layout_test.mjs compiles P_COUNT,
G_COUNT, P_E0 from core.h of web/STABLE and web/PREVIEW and checks them
(fails on the old editor: 32099fe and b983fbb both 123 / 77 / 115);
emulator.yml runs it before the site is deployed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
2026-11-30 21:14:12 +00:00

42 lines
2.9 KiB
JavaScript

// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant)
// (V10.8.77, a user: "the sound editor used to show modules, for a few updates now it is a vertical list") editor.html's
// knownLayout against the firmware's own counts: P_COUNT, G_COUNT and P_E0 compiled from core.h of each commit named
// (default: web/STABLE and web/PREVIEW), each must be a known layout, so the SOUND page shows its modules, not the plain
// list. Also: every older layout still known, a firmware with parameters appended at the end still known.
// node web/editor_layout_test.mjs [<commit> ...]
// Needs git (the commits fetched) and a C compiler. Run by emulator.yml before the site is deployed.
import fs from "fs";
import os from "os";
import path from "path";
import { execFileSync } from "child_process";
const HERE = path.dirname(new URL(import.meta.url).pathname);
const html = fs.readFileSync(path.join(HERE, "editor.html"), "utf8");
const a = html.indexOf("const EXPECT = "), b = html.indexOf("const P = {", a);
const knownLayout = new Function(html.slice(a, b) + "; return knownLayout;")();
let fails = 0;
const ok = (c, what) => { console.log(`${what.padEnd(96)} ${c ? "ok" : "FAIL"}`); if (!c) fails++; };
for (const [pcount, gcount, pe0] of [[123, 73, 115], [120, 66, 112], [99, 36, 91], [91, 27, 83], [57, 27, 49]])
ok(knownLayout({ pcount, gcount, pe0 }), `an older layout still known: P_COUNT ${pcount} G_COUNT ${gcount} P_E0 ${pe0}`);
ok(knownLayout({ pcount: 125, gcount: 80, pe0: 117 }), "parameters appended at the end (P_COUNT 125, G_COUNT 80): still known");
ok(!knownLayout({ pcount: 123, gcount: 77, pe0: 100 }), "an engine block not last (P_E0 100 of 123): the plain list");
const commits = process.argv.slice(2).length ? process.argv.slice(2)
: ["STABLE", "PREVIEW"].map((f) => fs.readFileSync(path.join(HERE, f), "utf8").trim());
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "edlay-"));
fs.writeFileSync(path.join(tmp, "pc.c"), '#include "core.h"\n#include <stdio.h>\nint main(void){printf("%d %d %d\\n",(int)P_COUNT,(int)G_COUNT,(int)P_E0);return 0;}\n');
for (const c of [...new Set(commits)]) {
const src = path.join(tmp, c);
fs.mkdirSync(src);
for (const f of execFileSync("git", ["ls-tree", "--name-only", c, "firmware/src/"], { encoding: "utf8" }).split("\n"))
if (f.endsWith(".h")) fs.writeFileSync(path.join(src, path.basename(f)), execFileSync("git", ["show", `${c}:${f}`], { maxBuffer: 1 << 26 }));
execFileSync("cc", ["-w", "-I" + src, path.join(tmp, "pc.c"), "-o", path.join(src, "pc")]);
const [pcount, gcount, pe0] = execFileSync(path.join(src, "pc"), { encoding: "utf8" }).trim().split(" ").map(Number);
ok(knownLayout({ pcount, gcount, pe0 }), `firmware ${c.slice(0, 7)} (P_COUNT ${pcount} G_COUNT ${gcount} P_E0 ${pe0}): the modules, not the plain list`);
}
fs.rmSync(tmp, { recursive: true, force: true });
console.log(fails ? `editor-layout: ${fails} FAILED` : "editor-layout: all ok");
process.exit(fails ? 1 : 0);