-
-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·107 lines (95 loc) · 2.72 KB
/
Copy pathrun_tests.sh
File metadata and controls
executable file
·107 lines (95 loc) · 2.72 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Convenience script for running tests
# Usage: ./run_tests.sh [options]
set -e
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Check if virtual environment is activated
if [[ -z "${VIRTUAL_ENV}" ]]; then
echo -e "${YELLOW}Virtual environment not activated. Activating .venv...${NC}"
if [ -d ".venv" ]; then
source .venv/bin/activate
else
echo -e "${RED}Error: .venv directory not found. Run: python -m venv .venv${NC}"
exit 1
fi
fi
# Parse command line arguments
COVERAGE=false
VERBOSE=false
QUICK=false
INTEGRATION=false
while [[ $# -gt 0 ]]; do
case $1 in
-c|--coverage)
COVERAGE=true
shift
;;
-v|--verbose)
VERBOSE=true
shift
;;
-q|--quick)
QUICK=true
shift
;;
-i|--integration)
INTEGRATION=true
shift
;;
-h|--help)
echo "Usage: ./run_tests.sh [options]"
echo ""
echo "Options:"
echo " -c, --coverage Run with coverage report"
echo " -v, --verbose Verbose output"
echo " -q, --quick Quick run (quiet mode)"
echo " -i, --integration Include integration tests"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " ./run_tests.sh # Run all unit tests"
echo " ./run_tests.sh -c # Run with coverage"
echo " ./run_tests.sh -q # Quick run"
echo " ./run_tests.sh -c -v # Coverage with verbose output"
exit 0
;;
*)
echo -e "${RED}Unknown option: $1${NC}"
echo "Use -h or --help for usage information"
exit 1
;;
esac
done
# Build pytest command
PYTEST_CMD="pytest tests/"
if [ "$INTEGRATION" = false ]; then
PYTEST_CMD="$PYTEST_CMD -m 'not integration'"
fi
if [ "$QUICK" = true ]; then
PYTEST_CMD="$PYTEST_CMD -q"
elif [ "$VERBOSE" = true ]; then
PYTEST_CMD="$PYTEST_CMD -v"
fi
if [ "$COVERAGE" = true ]; then
PYTEST_CMD="$PYTEST_CMD --cov=custom_components/llmvision --cov-report=term --cov-report=html"
fi
# Run tests
echo -e "${GREEN}Running tests...${NC}"
echo "Command: $PYTEST_CMD"
echo ""
if eval $PYTEST_CMD; then
echo ""
echo -e "${GREEN}✅ All tests passed!${NC}"
if [ "$COVERAGE" = true ]; then
echo -e "${GREEN}📊 Coverage report generated in htmlcov/index.html${NC}"
fi
exit 0
else
echo ""
echo -e "${RED}❌ Tests failed!${NC}"
exit 1
fi