Files
alexm b10a5c87a3
Test / gate (push) Canceled after 0s
A gate that does not depend on its machine, on a runner of its own
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).
2026-11-13 06:13:28 -05:00

37 lines
2.3 KiB
JavaScript

// SPDX-FileCopyrightText: 2026 Scientific Computing Studio, LLC
// SPDX-License-Identifier: Apache-2.0
// The pinned Dafny (scripts/dafny.py): its offline tests, and, when it has been fetched, that it is the pinned
// version and verifies a program.
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { spawnSync } from 'node:child_process';
// Under CI (the CI variable set, as Gitea and GitHub Actions set it) a missing tool fails these instead of skipping
// them: a skip in CI is how a gap hides. pixi brings python; CI fetches the pinned Dafny (pixi run dafny-fetch).
const py = spawnSync('python3', ['--version']);
const ROOT = new URL('..', import.meta.url).pathname;
test('the Dafny pin\'s own tests pass (python3)', { skip: py.status !== 0 && !process.env.CI ? 'python3 is not installed' : false }, () => {
assert.equal(py.status, 0, 'python3 is not installed, and CI must run this');
const r = spawnSync('python3', ['-m', 'unittest', 'discover', '-s', 'scripts/tests'], { encoding: 'utf8', cwd: ROOT });
assert.equal(r.status, 0, r.stderr);
});
const exe = ROOT + '.tools/dafny-4.11.0/dafny/dafny';
test('the fetched Dafny is the pinned one, and verifies a program', { skip: fs.existsSync(exe) || process.env.CI ? false : 'Dafny has not been fetched (pixi run dafny-fetch)' }, () => {
assert.ok(fs.existsSync(exe), 'Dafny has not been fetched, and CI must run this: pixi run dafny-fetch');
// as scripts/dafny.py runs it: .NET told not to look for ICU, which a slim image does not have
const env = { ...process.env, DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: '1' };
const v = spawnSync(exe, ['--version'], { encoding: 'utf8', env });
assert.match(v.stdout, /^4\.11\.0\+/, v.stderr);
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'pplus-dafny-'));
fs.writeFileSync(dir + '/max.dfy', 'method Max(a: int, b: int) returns (m: int) ensures m >= a && m >= b { if a > b { m := a; } else { m := b; } }\n');
const r = spawnSync(exe, ['verify', dir + '/max.dfy'], { encoding: 'utf8', env });
fs.rmSync(dir, { recursive: true, force: true });
assert.equal(r.status, 0, r.stdout + r.stderr);
assert.match(r.stdout, /1 verified, 0 errors/);
});