#!/usr/bin/env bash # # std.ch regression runner. Build each PRG against the current Five # compiler (caller's PWD must be the repo root) and execute it; non-zero # exit or "FAIL"/"NOT REJECTED" in stdout marks the run as failed. # # This deliberately runs in a temp scratch directory so the DBF/NTX # artifacts don't collide with each other across tests. set -e ROOT="$(cd "$(dirname "$0")/../.." && pwd)" FIVE="$ROOT/five" if [ ! -x "$FIVE" ]; then echo "five binary not found at $FIVE — run 'go build -o five ./cmd/five' first" >&2 exit 2 fi TESTS=( test_pp_stdch test_count test_sum_avg test_sum_multi test_copy test_sort test_list test_list_to_file test_total test_join test_update test_set_deleted test_unsupported test_block_comma test_compound_lhs test_join_hash test_sql_standards ) work="$(mktemp -d)" trap 'rm -rf "$work"' EXIT pass=0 fail=0 for name in "${TESTS[@]}"; do src="$ROOT/tests/std_ch/${name}.prg" # test_sql_standards lives in our suite but its `#include # "FiveSqlDef.ch"` resolves only when the FiveSql2 src files # are part of the same build (they sit alongside the .ch). # Other tests build standalone. extras=() if [ "$name" = "test_sql_standards" ]; then src="$ROOT/_FiveSql2/test/test_sql_standards.prg" extras=( $ROOT/_FiveSql2/src/*.prg ) fi bin="$work/${name}" if ! "$FIVE" build "$src" "${extras[@]}" -o "$bin" >/dev/null 2>"$work/${name}.err"; then echo "FAIL build $name" cat "$work/${name}.err" | sed 's/^/ /' fail=$((fail+1)) continue fi pushd "$work" >/dev/null if ! out="$("$bin" 2>&1)"; then echo "FAIL run $name" echo "$out" | sed 's/^/ /' fail=$((fail+1)) popd >/dev/null continue fi popd >/dev/null if echo "$out" | grep -qE 'FAIL|NOT REJECTED|expect.*got'; then echo "FAIL assert $name" echo "$out" | sed 's/^/ /' fail=$((fail+1)) continue fi echo "PASS $name" pass=$((pass+1)) done echo echo "================================================================" echo " Results: $pass / $((pass+fail)) passed" echo "================================================================" [ $fail -eq 0 ]