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 / argus_lock_validation.sh

63 lines · 2035 bytes Raw Blame History
1#!/usr/bin/env bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4
5set -u
6ROOT=$(cd "$(dirname "$0")/.." && pwd)
7TMP=$(mktemp -d "${TMPDIR:-/tmp}/omega-argus-lock.XXXXXX") || exit 2
8trap 'rm -rf "$TMP"' EXIT INT TERM
9GOOD=$(tr -d '\n' < "$ROOT/argus.lock")
10# The Makefile also parses aienos.lock at load; give the fixture the real one.
11cp "$ROOT/aienos.lock" "$TMP/aienos.lock"
12FAILS=0
13
14accept() {
15 local name=$1 content=$2
16 printf '%s' "$content" > "$TMP/argus.lock"
17 if make -s -C "$TMP" -f "$ROOT/Makefile" check-argus-lock >"$TMP/make.log" 2>&1; then
18 printf 'ok %s\n' "$name"
19 else
20 printf 'FAIL %s\n' "$name"
21 FAILS=$((FAILS + 1))
22 fi
23}
24
25reject() {
26 local name=$1 content=$2
27 printf '%s' "$content" > "$TMP/argus.lock"
28 if make -s -C "$TMP" -f "$ROOT/Makefile" check-argus-lock >"$TMP/make.log" 2>&1; then
29 printf 'FAIL %s\n' "$name"
30 FAILS=$((FAILS + 1))
31 elif grep -q 'argus.lock must contain exactly one lowercase 40-hex commit' "$TMP/make.log"; then
32 printf 'ok %s\n' "$name"
33 else
34 printf 'FAIL %s (wrong refusal)\n' "$name"
35 FAILS=$((FAILS + 1))
36 fi
37}
38
39accept "one lowercase commit" "$GOOD"$'\n'
40accept "commit without final newline" "$GOOD"
41reject "empty lock" ""
42reject "abbreviated commit" "${GOOD:0:39}"$'\n'
43reject "uppercase commit" "${GOOD^^}"$'\n'
44reject "leading whitespace" " $GOOD"$'\n'
45reject "trailing whitespace" "$GOOD "$'\n'
46reject "extra field" "$GOOD extra"$'\n'
47reject "option-like value" "--$GOOD"$'\n'
48reject "second commit" "$GOOD"$'\n'"$GOOD"$'\n'
49reject "trailing blank line" "$GOOD"$'\n\n'
50reject "trailing comment" "$GOOD"$'\n# comment\n'
51
52PWNED="$TMP/shell-metacharacters-ran"
53reject "shell metacharacters" "$GOOD ; touch $PWNED"$'\n'
54if [ -e "$PWNED" ]; then
55 echo "FAIL shell metacharacters executed"
56 FAILS=$((FAILS + 1))
57fi
58
59if [ "$FAILS" -ne 0 ]; then
60 echo "argus lock validation: $FAILS FAILED"
61 exit 1
62fi
63echo "argus lock validation: PASS"