Files
pplus-web/core/scripts/tests/test_dafny.py
T
alexmandClaude 82e18f7966 Move the engine core into core/, a project of its own (pplus-core)
What programs mean (the languages, translators, Mojo checker and
interpreter, prover, fuzzer, machine model, catalog problems and the Mojo
corpus with godbolt's stored answers) was mixed into the site's tree, so a
change to the prover and a change to a button went through the same gate
and the same docs. This moves all of it under core/, laid out as its own
repository, ready to be extracted with its history and pinned here as a
git submodule.

- core/: src/{engines,services,sync,mojo,exercises,curriculum,common},
  mojo/, syntax/mojo.xml, its tests (with Workspace and workForProblem in
  place of the site's Session), scripts (corpus pipeline, play, the
  exercise and probe starters, engines export/diff), and its docs
  (engines, trust, mojo-corpus, exercises, coverage). Its own pixi.toml,
  package.json, README, AGENTS.md and CI workflow.
- core/tests/boundary.test.mjs: library modules use no DOM, import no
  page widget, and import nothing outside src/.
- core/scripts/cli.mjs: pixi run cli check|run|prove|fuzz|translate.
- core/scripts/dafny.py: Dafny 4.11.0 pinned by version and SHA-256 per
  platform, fetched into .tools/ (pixi run dafny-fetch, pixi run dafny).
- The site imports core only as #core/<path>.js: an import map in
  index.html, "imports" in package.json for node, core's declarations for
  tsc. The site's TypeScript builds core first (npm run build).
- assemble.sh, the Quarto engine copy, the render cache key, check-pages,
  quarto-export and quarto-css read core/dist and core/mojo; quarto-css
  copies core's syntax/mojo.xml into the extension.
- Site tests that covered engines moved to core; the rest keep Session.
- README, AGENTS.md, docs/app.md, docs/deploy.md and the CI workflow
  describe the split (checkout with submodules; core's tests and corpus
  status run against the pinned commit).

Gate: site 110 pass; core 307 pass; corpus status --strict passes.
Manual check: the assembled site opens Bridge (count-base-proved),
Developer and Hardware (count-base) with the editor, the stepper and the
board, and no module errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
2026-10-05 05:43:58 +00:00

48 lines
1.8 KiB
Python

"""The Dafny pin, offline: every pinned platform has a release and a hash, an unpinned one is refused, and unpacking
keeps the executable bits Dafny and Z3 need."""
import os
import stat
import sys
import tempfile
import unittest
import zipfile
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
import dafny # noqa: E402
class Pin(unittest.TestCase):
def test_every_pinned_platform_names_this_version_and_a_sha256(self):
self.assertTrue(dafny.RELEASES)
for (system, machine), (asset, digest) in dafny.RELEASES.items():
self.assertIn(dafny.VERSION, asset, f"{system} {machine}")
self.assertRegex(digest, r"^[0-9a-f]{64}$", f"{system} {machine}")
def test_the_two_platforms_pixi_pins_are_covered(self):
self.assertIn(("Linux", "x86_64"), dafny.RELEASES)
self.assertIn(("Darwin", "arm64"), dafny.RELEASES)
def test_an_unpinned_platform_is_refused_by_name(self):
with self.assertRaises(SystemExit) as e:
dafny.release("Plan9", "mips")
self.assertIn("Plan9 mips", str(e.exception))
class Unpack(unittest.TestCase):
def test_unpacking_keeps_executable_bits(self):
with tempfile.TemporaryDirectory() as d:
z = Path(d) / "a.zip"
with zipfile.ZipFile(z, "w") as w:
info = zipfile.ZipInfo("dafny/dafny")
info.external_attr = (0o755 | stat.S_IFREG) << 16
w.writestr(info, "#!/bin/sh\n")
w.writestr("dafny/readme.txt", "text")
dafny.unpack(z, Path(d) / "out")
self.assertTrue(os.access(Path(d) / "out/dafny/dafny", os.X_OK))
self.assertTrue((Path(d) / "out/dafny/readme.txt").exists())
if __name__ == "__main__":
unittest.main()