Home /Modules/impl/run_class_dispatch_tests.sh

run_class_dispatch_tests.sh

impl/tests/class_dispatch/run_class_dispatch_tests.sh · 22 line(s) · bash

#!/usr/bin/env bash
set -euo pipefail
BIN="${1:-impl/build/sleela}"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
cd "$ROOT"
export SLEELA_SHEET="${SLEELA_SHEET:-$ROOT/SHEET.sheet}"
export SLEELA_SHA256_MANIFEST="${SLEELA_SHA256_MANIFEST:-$ROOT/security/sha256-manifest.json}"

# Security verification is intentionally visible to users, but it is not
# program output. Filter only the known verification/defender records before
# comparing the exact class-dispatch fixture.
actual="$("$BIN" run impl/tests/class_dispatch/class_instance_dispatch.sleela | sed -E \
  -e '/^verification: PASS \([0-9]+ item\(s\)\)$/d' \
  -e '/^\[security\]/d' \
  -e '/^\[defender\]/d')"
expected=$'1\n2\n0\n1\n2'
if [[ "$actual" != "$expected" ]]; then
  printf 'class dispatch regression failed\nExpected:\n%s\nActual:\n%s\n' "$expected" "$actual" >&2
  exit 1
fi
printf 'class dispatch regression: PASS\n'