test(runner): run.sh golden testleri de kapsıyor

Önceden yalnızca birim testleri (test_type, test_diagnostic) çalıştırıyordu.
Artık tests/golden/**/*.sqt dosyaları da .expected çıktısıyla karşılaştırılıyor.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
saqut 2026-06-20 15:21:00 +03:00
parent 34447d082e
commit 91fd64d06a
1 changed files with 34 additions and 1 deletions

View File

@ -1,16 +1,49 @@
#!/usr/bin/env bash
# saQut birim testleri — çerçevesiz (assert tabanlı), tek komutla.
# saQut test koşucusu — birim testler + golden testler
# Kullanım: bash tests/run.sh
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CXX="${CXX:-g++}"
FLAGS=(-std=c++20 -Wall -Wextra -I"$ROOT/src")
SAQUT="$ROOT/build/saqut"
# ── Birim testler ─────────────────────────────────────────────────────────────
for t in test_type test_diagnostic; do
echo "=== $t ==="
"$CXX" "${FLAGS[@]}" "$ROOT/tests/$t.cpp" -o "/tmp/saqut_$t"
"/tmp/saqut_$t"
done
# ── Golden testler ────────────────────────────────────────────────────────────
echo "=== golden ==="
if [ ! -x "$SAQUT" ]; then
echo "HATA: $SAQUT bulunamadı — önce derleyin (cmake --build build)"
exit 1
fi
PASS=0; FAIL=0
while IFS= read -r -d '' sqt; do
dir=$(dirname "$sqt")
base=$(basename "$sqt" .sqt)
exp="$dir/$base.expected"
[ -f "$exp" ] || continue
actual=$("$SAQUT" run "$sqt" 2>/dev/null) || true
expected=$(cat "$exp")
if [ "$actual" = "$expected" ]; then
PASS=$((PASS + 1))
else
echo " FAIL: ${sqt#"$ROOT"/}"
echo " beklenen : $(echo "$expected" | head -1)"
echo " gerçek : $(echo "$actual" | head -1)"
FAIL=$((FAIL + 1))
fi
done < <(find "$ROOT/tests/golden" -name "*.sqt" -print0 | sort -z)
echo " $PASS geçti, $FAIL başarısız"
[ "$FAIL" -eq 0 ] || exit 1
echo "=== TUM TESTLER GECTI ==="