interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tests / test_receipt_commit_guard.sh

31 lines · 1516 bytes Raw Blame History
1#!/bin/sh
2# tests/test_receipt_commit_guard.sh -- receipt_commit_resolve stamps HEAD and fails closed otherwise.
3set -u
4ROOT=$(cd "$(dirname "$0")/.." && pwd -P)
5. "$ROOT/tests/receipt_commit.sh"
6HEAD=$(git -C "$ROOT" rev-parse HEAD)
7fail() { echo "FAIL: $1"; exit 1; }
8
9unset QUALIFIED_IMPLEMENTATION_COMMIT RECEIPT_COMMIT
10receipt_commit_resolve "$ROOT" || fail "clean tree at HEAD refused"
11[ "$QUALIFIED_COMMIT" = "$HEAD" ] || fail "QUALIFIED_COMMIT $QUALIFIED_COMMIT is not HEAD $HEAD"
12[ "$RECEIPT_COMMIT" = "pending-receipt-commit" ] || fail "RECEIPT_COMMIT not a placeholder"
13echo "PASS: HEAD $HEAD stamped"
14
15QUALIFIED_IMPLEMENTATION_COMMIT=$HEAD receipt_commit_resolve "$ROOT" || fail "matching override refused"
16echo "PASS: override equal to HEAD accepted"
17
18if QUALIFIED_IMPLEMENTATION_COMMIT=d25349e4bf4a820dbcff0dd6a593d1db7b454a0b receipt_commit_resolve "$ROOT" 2>/dev/null; then
19 fail "foreign sha accepted"
20fi
21echo "PASS: foreign sha refused (negative control)"
22
23tmp=$(mktemp -d) && trap 'rm -rf "$tmp"' EXIT
24if receipt_commit_resolve "$tmp" 2>/dev/null; then fail "non-git directory accepted"; fi
25echo "PASS: non-git tree refused (negative control)"
26
27git -C "$ROOT" worktree add -q "$tmp/wt" HEAD || fail "worktree"
28printf '\n' >> "$tmp/wt/tests/receipt_commit.sh"
29if receipt_commit_resolve "$tmp/wt" 2>/dev/null; then git -C "$ROOT" worktree remove --force "$tmp/wt"; fail "dirty tree accepted"; fi
30git -C "$ROOT" worktree remove --force "$tmp/wt"
31echo "PASS: dirty tree refused (negative control)"