Reference implementation of the strap-beam generators at revision 8.0.0, kept so the acceptance oracle can be regenerated. Not a live target; the running application has no OpenSCAD dependency. The oracle holds 123 frozen cases, 113 accepted and 10 rejected, produced by OpenSCAD 2021.01 with BOSL2 at 92d697c2. The ten rejections are part of the contract: a port that accepts them is wrong. tests/test_oracle.py specifies the port API and was written before the port, so the interface follows from what must be verified rather than what is convenient to implement. Proven by adversarial stub: a build() that rejects everything passes all 10 rejection tests and fails all 226 acceptance tests.
62 lines
2.3 KiB
Bash
62 lines
2.3 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# Build the pinned toolchain and prove the committed oracle still reproduces.
|
|
#
|
|
# ./tools/reference-toolchain/verify.sh # verify the hash only
|
|
# ./tools/reference-toolchain/verify.sh --full # regenerate and compare
|
|
#
|
|
# --full runs all 123 cases through OpenSCAD. On the staging host that takes a
|
|
# while: the solvers are single-threaded and the CPU is old. That is expected.
|
|
|
|
set -euo pipefail
|
|
|
|
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
IMAGE="mechcomp/reference-toolchain:8.0.0"
|
|
EXPECTED="ddd0f1548379205dd0c652ec07285b0dae331e52ff0a0437005dfc6cddcc2cb2"
|
|
|
|
echo "==> building ${IMAGE}"
|
|
docker build -t "${IMAGE}" "${REPO}/tools/reference-toolchain"
|
|
|
|
echo
|
|
echo "==> toolchain versions"
|
|
docker run --rm "${IMAGE}" openscad --version
|
|
docker run --rm "${IMAGE}" git -C /BOSL2 rev-parse HEAD 2>/dev/null \
|
|
|| echo "(BOSL2 .git removed at build time; commit is pinned by ARG)"
|
|
|
|
echo
|
|
echo "==> verifying the committed oracle"
|
|
python3 "${REPO}/fixtures/strap-beam-8.0.0/make_fixtures.py" --verify
|
|
|
|
if [[ "${1:-}" == "--full" ]]; then
|
|
echo
|
|
echo "==> regenerating all 123 cases inside the pinned toolchain"
|
|
tmp="$(mktemp -d)"
|
|
trap 'rm -rf "${tmp}"' EXIT
|
|
cp "${REPO}/fixtures/strap-beam-8.0.0/strap-beam-fixtures-8.0.0.json" "${tmp}/before.json"
|
|
|
|
docker run --rm -v "${REPO}:/repo" "${IMAGE}" \
|
|
python3 /repo/fixtures/strap-beam-8.0.0/make_fixtures.py --regenerate
|
|
|
|
echo
|
|
echo "==> comparing against the committed oracle"
|
|
if diff -q "${tmp}/before.json" \
|
|
"${REPO}/fixtures/strap-beam-8.0.0/strap-beam-fixtures-8.0.0.json" >/dev/null; then
|
|
echo "OK - byte-identical."
|
|
else
|
|
echo "DIFFERS from the committed oracle." >&2
|
|
echo "The 'frozen' date changes on every regeneration, so a one-line" >&2
|
|
echo "diff there is expected. Any other difference means the toolchain" >&2
|
|
echo "has drifted; investigate before proceeding." >&2
|
|
diff "${tmp}/before.json" \
|
|
"${REPO}/fixtures/strap-beam-8.0.0/strap-beam-fixtures-8.0.0.json" | head -40 >&2
|
|
cp "${tmp}/before.json" \
|
|
"${REPO}/fixtures/strap-beam-8.0.0/strap-beam-fixtures-8.0.0.json"
|
|
echo >&2
|
|
echo "The committed oracle has been restored. Nothing was overwritten." >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo
|
|
echo "expected sha256: ${EXPECTED}"
|