test: add unit tests for brevity bonus and blank start linguistic match
This commit is contained in:
28
scripts/pre_commit_tests.sh
Executable file
28
scripts/pre_commit_tests.sh
Executable 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!"
|
||||
Reference in New Issue
Block a user