-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-runner.sh
More file actions
executable file
·44 lines (38 loc) · 1.14 KB
/
test-runner.sh
File metadata and controls
executable file
·44 lines (38 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
"""
Test runner hook for Husky-style pre-push setup.
This hook runs tests and coverage checks before pushing.
"""
echo "🧪 Running tests and coverage checks..."
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check if pytest is available
if ! command_exists pytest; then
echo "❌ pytest not found. Please install it first:"
echo " pip install pytest pytest-cov"
exit 1
fi
# Run tests
echo " - Running tests..."
if pytest --html=tests/test-report/test-report.html; then
echo " ✅ All tests passed"
else
echo " ❌ Tests failed. Please fix before pushing."
exit 1
fi
# Run coverage check
echo " - Checking test coverage..."
if command_exists pytest; then
if pytest --cov=contentstack_utils --cov-report=term-missing; then
echo " ✅ Coverage check completed"
else
echo " ❌ Coverage check failed. Please improve test coverage."
exit 1
fi
else
echo " ⚠️ pytest-cov not installed, skipping coverage check"
echo " 💡 Install with: pip install pytest-cov"
fi
echo "✅ All test checks passed!"