feat: move corpus to library
Test / test (push) Failing after 1m38s

This commit is contained in:
alexm committed 2026-10-06 10:27:46 -04:00
1 parent 5b8b079165
commit cae5cff55a
1350 files changed
+197 -941995

No files matched your search

+6 -6
View File
@@ -8,7 +8,7 @@ import { listingFunctions } from '../dist/services/godbolt.js';
import { parseAsm } from '../dist/services/asm.js';
const ROOT = new URL('..', import.meta.url).pathname;
const GOLDEN = ROOT + 'mojo/golden';
const GOLDEN = ROOT + 'library/mojo/golden';
const mods = { forSimulator, simulatorSetup, listingFunctions };
test('stripHeader drops what emit_ts.py drops, and says how many lines went', () => {
@@ -28,7 +28,7 @@ test('readHeader reads the keys verify.py knows and ignores other comments', ()
});
test('a golden is used only for the exact source, mode and arguments it answered', () => {
const probe = fs.readFileSync(ROOT + 'mojo/probes/godbolt-line-tables-O0.mojo', 'utf8');
const probe = fs.readFileSync(ROOT + 'library/mojo/probes/godbolt-line-tables-O0.mojo', 'utf8');
const h = readHeader(probe);
assert.ok(findGolden(GOLDEN, probe, h.mode, h.args ?? ''), 'the committed answer for this probe is found');
assert.equal(findGolden(GOLDEN, probe + ' ', h.mode, h.args ?? ''), null, 'one extra character and the answer no longer applies');
@@ -37,8 +37,8 @@ test('a golden is used only for the exact source, mode and arguments it answered
test('real godbolt answers become x86-64 panes the assembler accepts, with lines that point into the shown source', () => {
let made = 0;
for (const f of fs.readdirSync(ROOT + 'mojo/probes').filter((x) => x.endsWith('.mojo'))) {
const text = fs.readFileSync(ROOT + 'mojo/probes/' + f, 'utf8');
for (const f of fs.readdirSync(ROOT + 'library/mojo/probes').filter((x) => x.endsWith('.mojo'))) {
const text = fs.readFileSync(ROOT + 'library/mojo/probes/' + f, 'utf8');
if (!/^# mode: (asm|both)/m.test(text)) continue;
const r = buildListing(text, GOLDEN, mods);
if (r.why) continue; // e.g. built without -O0, so the optimizer inlined every function
@@ -64,12 +64,12 @@ test('render keeps the header and interface, and writes programs in name order',
assert.ok(out.endsWith('};\n'));
});
test('every exercise that names a Mojo program has that program in mojo/local/', () => {
test('every exercise that names a Mojo program has that program in library/mojo/local/', () => {
const dir = ROOT + 'src/exercises/';
const missing = [];
for (const f of fs.readdirSync(dir).filter((x) => x.endsWith('.ts') && !x.startsWith('_'))) {
const m = /mojoProgram:\s*['"]([^'"]+)['"]/.exec(fs.readFileSync(dir + f, 'utf8'));
if (m && !fs.existsSync(ROOT + `mojo/local/${m[1]}.mojo`)) missing.push(`${f} -> mojo/local/${m[1]}.mojo`);
if (m && !fs.existsSync(ROOT + `library/mojo/local/${m[1]}.mojo`)) missing.push(`${f} -> library/mojo/local/${m[1]}.mojo`);
}
assert.deepEqual(missing, [], 'create the file, or remove `mojoProgram` from the exercise; until then `pixi run play` will not regenerate programs.ts, because the catalog would throw');
});