A gate that does not depend on its machine, on a runner of its own
Test / gate (push) Canceled after 0s
Test / gate (push) Canceled after 0s
The gate first ran on the server that deploys the site: a slow container with no C compiler and no ICU. Ten tests failed there on correct code, and no Mojo program could be built at all. - The workflows ask for a runner labeled heavy, not the deploy server: the gate builds and runs some 300 Mojo programs and fuzzes. docs/ci.md says how to register one. With none registered a run waits. - The pinned environment has a C compiler on Linux (gcc, with its C library pinned to glibc 2.34): mojo build links with the C compiler it finds, and conda-forge's default links against a C library too old for Mojo's runtime. mojo-local reports a program that could not be linked as that, and does not keep the answer. - The pinned Dafny runs without ICU, and dafny-fetch fails when the Dafny it fetched does not start. - A test's time limit is processor time at the machine's pace (tests/helpers/pace.mjs). - The prover's time on the clock is the caller's: provePseudo and Workspace.proofBudgetMs take it, the Prove tab's 3 seconds stay the default, and the command line, library-check and the tests use none, so their answers are the counted budgets' alone. - The library pointer moves to its workflow change (e5ae090).
This commit is contained in:
31 files changed
+427
-104
No files matched your search
@@ -5,12 +5,14 @@
|
||||
// never "proved" and never a missing obligation (docs/limits.md).
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { studyOf, provePseudo } from '../dist/services/pseudo.js';
|
||||
import { verify } from '../dist/engines/pseudo/vcgen.js';
|
||||
import { prove } from '../dist/engines/pseudo/solver.js';
|
||||
import { sym, num, cmp, ite, neg, add, key, show, TOO_LARGE, MAX_KEY } from '../dist/engines/pseudo/logic.js';
|
||||
import { NO_CLOCK, within } from './helpers/pace.mjs';
|
||||
|
||||
const DIST = fileURLToPath(new URL('../dist/', import.meta.url));
|
||||
const absOf = (n) => `${'ABS('.repeat(n)}X${')'.repeat(n)}`;
|
||||
@@ -30,8 +32,9 @@ test('nested ABS and a matho pane of 20 bars are proved in a 128 MB heap: open,
|
||||
const { studyOf, provePseudo } = await import(process.env.DIST + 'services/pseudo.js');
|
||||
const { Workspace } = await import(process.env.DIST + 'common/workspace.js');
|
||||
const src = 'FUNCTION F(X : INTEGER) RETURNS INTEGER\\n ENSURE RESULT >= 0\\n RETURN ${absOf(20)}\\nENDFUNCTION\\n';
|
||||
const r = provePseudo(studyOf(src));
|
||||
const r = provePseudo(studyOf(src), { budgetMs: Infinity });
|
||||
const ws = new Workspace({ sources: { matho: 'f(x) = ${'|'.repeat(20)}x${'|'.repeat(20)}' }, lang: 'matho' });
|
||||
ws.proofBudgetMs = Infinity;
|
||||
const m = ws.proof();
|
||||
console.log(JSON.stringify({ counts: r.counts, ob: r.units[0].obligations.map((o) => [o.kind, o.status, o.reason]), matho: m && m.report.counts, fault: ws.proofFault }));
|
||||
`);
|
||||
@@ -75,24 +78,48 @@ test('prove: past its work the answer is unknown, too large to prove here, and n
|
||||
|
||||
test('a subroutine past the checker\'s work is partial and says so: nothing in it proved, the same answer every time', () => {
|
||||
const p = program(nestedFor(30));
|
||||
const r1 = verify(p, { budgetMs: 600000 });
|
||||
const r2 = verify(p, { budgetMs: 600000 });
|
||||
const r1 = verify(p, NO_CLOCK);
|
||||
const r2 = verify(p, NO_CLOCK);
|
||||
assert.equal(r1.units[0].partial, true);
|
||||
const note = r1.units[0].notes.find((n) => n.kind === 'too-large');
|
||||
assert.match(note.text, /too large to prove here.*nothing in it is marked proved/);
|
||||
assert.deepEqual(r2.units[0].obligations.map((o) => [o.kind, o.line, o.status]), r1.units[0].obligations.map((o) => [o.kind, o.line, o.status]));
|
||||
const report = provePseudo(studyOf(nestedFor(30)));
|
||||
const report = provePseudo(studyOf(nestedFor(30)), NO_CLOCK);
|
||||
assert.equal(report.counts.proved, 0);
|
||||
// two levels of the same loops are proved as before
|
||||
const small = verify(program(nestedFor(2)));
|
||||
const small = verify(program(nestedFor(2)), NO_CLOCK);
|
||||
assert.equal(small.units[0].partial, false);
|
||||
assert.ok(small.counts.proved >= 1);
|
||||
});
|
||||
|
||||
test('the time on the clock is the caller\'s: run out, it leaves a subroutine partial and proves less, never more; the command line has none', async () => {
|
||||
const { Workspace } = await import('../dist/common/workspace.js');
|
||||
const src = fs.readFileSync(new URL('../library/pseudo/programs/19-max-subarray.pseudo', import.meta.url), 'utf8');
|
||||
const whole = provePseudo(studyOf(src), NO_CLOCK);
|
||||
assert.deepEqual(whole.counts, { proved: 6, broken: 0, open: 0, total: 6 });
|
||||
// a clock that has already run out (what 3 seconds were on CI's runner): the subroutine with the loop is partial
|
||||
const cut = provePseudo(studyOf(src), { budgetMs: -1 });
|
||||
assert.equal(cut.units.find((u) => u.name === 'MAX_SUBARRAY').partial, true);
|
||||
assert.ok(cut.counts.proved < 6 && cut.counts.broken === 0, JSON.stringify(cut.counts));
|
||||
// a Workspace hands its own on, and proves again when it changes
|
||||
const ws = new Workspace({ sources: { pseudo: src }, lang: 'pseudo' });
|
||||
ws.proofBudgetMs = -1;
|
||||
assert.ok(ws.proof().report.counts.proved < 6);
|
||||
ws.proofBudgetMs = Infinity;
|
||||
assert.equal(ws.proof().report.counts.proved, 6);
|
||||
// the command line has no clock unless it is given one, and refuses one that is not a time
|
||||
const cli = (...args) => spawnSync(process.execPath, ['scripts/cli.mjs', 'prove', 'library/pseudo/programs/19-max-subarray.pseudo', ...args], { cwd: fileURLToPath(new URL('..', import.meta.url)), encoding: 'utf8' });
|
||||
assert.equal(cli().stdout.trim().split('\n').pop(), '6 proved, 0 broken, 0 open');
|
||||
assert.equal(cli('--budget-ms', '600000').stdout.trim().split('\n').pop(), '6 proved, 0 broken, 0 open');
|
||||
const bad = cli('--budget-ms', 'soon');
|
||||
assert.equal(bad.status, 2);
|
||||
assert.match(bad.stderr, /--budget-ms takes a number of milliseconds above 0/);
|
||||
});
|
||||
|
||||
test('past a subroutine\'s proving work, every obligation is still listed, open and too large to prove here', () => {
|
||||
const n = 40;
|
||||
const src = fn('X : INTEGER', `${Array.from({ length: n }, (_, k) => ` ASSERT ${absOf(12).replace('X)', `X - ${k})`)} >= 0`).join('\n')}\n RETURN X`);
|
||||
const r = verify(program(src), { budgetMs: 600000 });
|
||||
const r = verify(program(src), NO_CLOCK);
|
||||
const obs = r.units[0].obligations;
|
||||
assert.equal(obs.length, n);
|
||||
assert.ok(obs.every((o) => o.status === 'unknown'));
|
||||
@@ -101,7 +128,7 @@ test('past a subroutine\'s proving work, every obligation is still listed, open
|
||||
|
||||
test('past a program\'s work, the subroutines after it are partial and say so', () => {
|
||||
const src = [nestedFor(30, 'A'), nestedFor(30, 'B'), nestedFor(30, 'C'), fn('X : INTEGER', ' RETURN X', ' ENSURE RESULT == X\n').replace('FUNCTION F(', 'FUNCTION D(')].join('\n');
|
||||
const r = verify(program(src), { budgetMs: 600000 });
|
||||
const r = verify(program(src), NO_CLOCK);
|
||||
assert.deepEqual(r.units.map((u) => u.partial), [true, true, true, true]);
|
||||
for (const u of r.units) assert.ok(u.notes.some((n) => n.kind === 'too-large'), u.name);
|
||||
assert.equal(r.counts.proved, 0);
|
||||
@@ -146,12 +173,13 @@ test('checkProperties: maxWork bounds the steps and quantifier positions of all
|
||||
|
||||
test('the Prove tab\'s cross-check of a routine whose ENSURE nests quantifiers ends within its budget of work', async () => {
|
||||
const { CROSS_CHECK_ROUTINE } = await import('../dist/services/pseudo.js');
|
||||
const t0 = Date.now();
|
||||
const r = provePseudo(studyOf(quantified(8)));
|
||||
assert.equal(r.counts.broken, 0);
|
||||
// before the budget one input of this routine visited 5,000,000 positions (about 7 seconds); the limit is
|
||||
// processor time at this machine's pace (tests/helpers/pace.mjs), with no time on the prover's clock
|
||||
within(30000, 'the cross-check of 8 nested quantifiers', () => {
|
||||
const r = provePseudo(studyOf(quantified(8)), NO_CLOCK);
|
||||
assert.equal(r.counts.broken, 0);
|
||||
});
|
||||
assert.ok(CROSS_CHECK_ROUTINE <= 1_000_000);
|
||||
// before the budget one input of this routine visited 5,000,000 positions (about 7 seconds)
|
||||
assert.ok(Date.now() - t0 < 30000);
|
||||
});
|
||||
|
||||
/* ---------- the fuzzer (Workspace.fuzz, the Tests view) ---------- */
|
||||
@@ -235,13 +263,14 @@ test('a value built from thousands of operations one inside another becomes an u
|
||||
const { Workspace } = await import('../dist/common/workspace.js');
|
||||
// 60 lines of 390-term sums: a value 23,000 operations deep, which ran the prover past the engine's stack
|
||||
const src = fn('X : INTEGER', ` DECLARE T : INTEGER\n T <- 0\n${` T <- T${' + X'.repeat(390)}\n`.repeat(60)} ASSERT X == X\n RETURN T`, ' REQUIRE X >= 0\n ENSURE RESULT >= 0\n');
|
||||
const r = verify(program(src), { budgetMs: 600000 });
|
||||
const r = verify(program(src), NO_CLOCK);
|
||||
assert.equal(r.units[0].partial, false);
|
||||
assert.match(r.units[0].notes.find((n) => n.kind === 'too-deep').text, new RegExp(`more than ${MAX_DEPTH} operations one inside another`));
|
||||
// what does not depend on the value is still proved, and what does is open
|
||||
assert.deepEqual(r.units[0].obligations.map((o) => [o.kind, o.status]), [['assert', 'proved'], ['ensure', 'unknown']]);
|
||||
const ws = new Workspace({ sources: { pseudo: src }, lang: 'pseudo' });
|
||||
assert.ok(!ws.allDiagnostics().some((d) => d.id === 'engine-stop'));
|
||||
ws.proofBudgetMs = Infinity;
|
||||
assert.equal(ws.proof().report.counts.total, 2);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user