Long overdue "make fmt" sorry about this one

This commit is contained in:
Zef Hemel
2026-07-14 15:58:15 +02:00
parent 9e022d7668
commit 28f1f8af16
167 changed files with 6359 additions and 5795 deletions
+18 -32
View File
@@ -24,10 +24,7 @@ for (const file of testFiles) {
}
// Library API Lua tests (stdlib + jsonschema + library code pre-loaded)
const libraryApisDir = resolve(
__dirname,
"../../libraries/Library/Std/APIs",
);
const libraryApisDir = resolve(__dirname, "../../libraries/Library/Std/APIs");
const libraryTestFiles = readdirSync(libraryApisDir, { recursive: true })
.filter((f): f is string => typeof f === "string" && f.endsWith("_test.lua"))
.sort();
@@ -38,9 +35,7 @@ for (const file of libraryTestFiles) {
// This is required for multi-word library pages that the derivation below
// cannot reach.
const testSource = readFileSync(resolve(libraryApisDir, file), "utf-8");
const companionMatch = testSource.match(
/^--\s*companion:\s*(.+?)\s*$/m,
);
const companionMatch = testSource.match(/^--\s*companion:\s*(.+?)\s*$/m);
let libraryMdPath: string;
if (companionMatch) {
libraryMdPath = resolve(libraryApisDir, companionMatch[1]);
@@ -60,10 +55,10 @@ for (const file of libraryTestFiles) {
libraryMdPath = resolve(libraryApisDir, `${libraryName}.md`);
}
test(`[Lua] ${file}`, async () => {
await runLuaTest(
resolve(libraryApisDir, file),
{ isAbsolutePath: true, preloadMdPath: libraryMdPath },
);
await runLuaTest(resolve(libraryApisDir, file), {
isAbsolutePath: true,
preloadMdPath: libraryMdPath,
});
});
}
@@ -116,9 +111,8 @@ async function runLuaTest(
if (opts.preloadMdPath) {
// Provide a minimal jsonschema table so widget.new validation works
const jsonschemaTbl = new LuaTable();
await jsonschemaTbl.set(
"validateObject",
(schema: any, obj: any) => validateObject(schema, obj),
await jsonschemaTbl.set("validateObject", (schema: any, obj: any) =>
validateObject(schema, obj),
);
env.set("jsonschema", jsonschemaTbl);
@@ -140,30 +134,22 @@ async function runLuaTest(
return String(path).split(".").join("\0");
};
const configTbl = new LuaTable();
await configTbl.set(
"set",
(path: unknown, value: unknown) => {
configStore.set(pathToKey(path), value);
},
);
await configTbl.set(
"get",
(path: unknown, defaultValue: unknown) => {
const key = pathToKey(path);
return configStore.has(key)
? configStore.get(key)
: (defaultValue ?? null);
},
);
await configTbl.set("set", (path: unknown, value: unknown) => {
configStore.set(pathToKey(path), value);
});
await configTbl.set("get", (path: unknown, defaultValue: unknown) => {
const key = pathToKey(path);
return configStore.has(key)
? configStore.get(key)
: (defaultValue ?? null);
});
env.set("config", configTbl);
let mdText: string;
try {
mdText = await readFile(opts.preloadMdPath, "utf-8");
} catch {
throw new Error(
`Library preload file not found: ${opts.preloadMdPath}`,
);
throw new Error(`Library preload file not found: ${opts.preloadMdPath}`);
}
const libLua = extractSpaceLuaFromPageText(mdText);
if (libLua) {