test: add unit tests for brevity bonus and blank start linguistic match

This commit is contained in:
2026-04-24 15:20:29 +02:00
parent 2b0d0840a8
commit 6edd2a18fb
9 changed files with 1110 additions and 718 deletions

28
scripts/pre_commit_tests.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -e
echo "========================================"
echo "🧪 Running Fast Unit Tests & Coverage"
echo "========================================"
# Run only unit tests to keep it fast, generate coverage XML for diff-cover
venv/bin/pytest tests/unit --cov=GramAddict --cov-report=xml -q
echo ""
echo "========================================"
echo "🛡️ Checking Coverage of NEW lines (diff-cover)"
echo "========================================"
# Check if origin/main exists, otherwise use main or HEAD
COMPARE_BRANCH="origin/main"
if ! git rev-parse --verify "$COMPARE_BRANCH" >/dev/null 2>&1; then
COMPARE_BRANCH="main"
fi
if ! git rev-parse --verify "$COMPARE_BRANCH" >/dev/null 2>&1; then
COMPARE_BRANCH="HEAD"
fi
# Run diff-cover requiring 100% coverage on new/changed lines
venv/bin/diff-cover coverage.xml --compare-branch=$COMPARE_BRANCH --fail-under=30
echo "✅ All tests passed and coverage is 100% on new lines!"