Build, test, deploy / site (push) Successful in 7m38s
In a container running the tests on two processors, the Quarto gallery's proved example was rendered with the warning that time ran out: the generated inputs that cross-check a proof had been cut short by the 3-second clock, with every claim already proved. core 941af6b counts that only where a claim is still open. The tests that hold what a proof finds give it time to spare, and the browser-side request builder takes prove-seconds as the Lua filter does.
52 lines
3.3 KiB
JavaScript
52 lines
3.3 KiB
JavaScript
// SPDX-FileCopyrightText: 2026 Scientific Computing Studio, LLC
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// The app's "With Quarto" page (#/quarto, src/ui/quarto.ts): its samples must show what a page gets from the
|
|
// extension, and every program in it must run as its header says.
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { installDocument } from '../dist/quarto/dom.js';
|
|
import { langOfFile } from '../dist/quarto/program.js';
|
|
|
|
installDocument();
|
|
const { renderStatic } = await import('../dist/quarto/render.js');
|
|
const { parseRoute, routeFor } = await import('../dist/core/state.js');
|
|
|
|
test('the gallery\'s samples render as a page would get them, and every run in it prints what its file says', async () => {
|
|
const { galleryFiles, SAMPLES } = await import('../dist/ui/quarto.js');
|
|
const { SHORTCODES, requestFor, liveStateFor, shortcodeText } = await import('../dist/quarto/shortcodes.js');
|
|
const files = galleryFiles();
|
|
const named = new Set(SAMPLES.map((s) => s.name));
|
|
// every shortcode has a card; the machine's one-view shortcodes share a card with a menu of them all
|
|
for (const d of SHORTCODES) assert.ok(named.has(d.name) || (d.kind === 'machine' && d.hw && SAMPLES.some((x) => x.explore)), `the gallery shows ${d.name}`);
|
|
for (const s of SAMPLES) {
|
|
for (const [k, v] of Object.entries(s.attrs)) if (['lingo', 'matho', 'pseudo', 'speco', 'mojo', 'asm', 'setup'].includes(k)) assert.ok(files[v] !== undefined, `${s.name} names ${v}`);
|
|
assert.match(shortcodeText(s.name, s.attrs), new RegExp(`^\\{\\{< ${s.name} .* >\\}\\}$`));
|
|
const def = SHORTCODES.find((d) => d.name === s.name);
|
|
if (def.kind === 'live') { assert.ok(Object.keys(liveStateFor(s.attrs, files).sources).length, s.name); continue; }
|
|
if (def.kind !== 'rendered' && def.kind !== 'machine') continue;
|
|
const view = def.view ?? (s.attrs.view === 'dataflow' ? 'data' : s.attrs.view);
|
|
const req = requestFor(view, s.attrs, files);
|
|
if (def.hw) req.hw = [def.hw];
|
|
// a proof with time to spare: the 3 seconds a page gets by default can run out on a loaded machine, and the
|
|
// render then warns (prove-seconds); what the sample proves is held here, not how fast this machine is
|
|
if (view === 'proof') req.proveSeconds = 600;
|
|
const r = renderStatic(req);
|
|
assert.deepEqual(r.warnings, [], `${s.name} ${JSON.stringify(s.attrs)}`);
|
|
if (r.expect) assert.ok(r.expect.ok, `${s.name}: ${JSON.stringify(r.expect)}`);
|
|
}
|
|
// the files' own headers hold: each run prints its EXPECT lines, each stop is the one it names
|
|
for (const [name, text] of Object.entries(files)) {
|
|
const lang = langOfFile(name);
|
|
if (!lang || lang === 'speco' || lang === 'asm') continue;
|
|
const r = renderStatic({ view: 'run', files: { [lang]: text } });
|
|
if (r.expect) assert.ok(r.expect.ok, `${name}: ${JSON.stringify(r.expect)}`);
|
|
}
|
|
});
|
|
|
|
test('#/quarto is the gallery, and its sections are links', () => {
|
|
assert.deepEqual(parseRoute('#/quarto'), { kind: 'quarto' });
|
|
assert.deepEqual(parseRoute('#/quarto#pplus-steps'), { kind: 'quarto', anchor: 'pplus-steps' });
|
|
assert.equal(routeFor({ kind: 'quarto', anchor: 'setup' }), '#/quarto#setup');
|
|
assert.deepEqual(parseRoute('#/quarto/x'), { kind: 'home' });
|
|
});
|