-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
152 lines (122 loc) · 5.07 KB
/
Makefile
File metadata and controls
152 lines (122 loc) · 5.07 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Makefile for Contract Clause Extractor Tests
# Provides convenient shortcuts for running tests
.PHONY: help test test-unit test-integration test-smoke test-cov test-fast test-all clean install-test
# Colors for output
BLUE := \033[0;34m
GREEN := \033[0;32m
RED := \033[0;31m
NC := \033[0m # No Color
help: ## Show this help message
@echo '$(BLUE)Contract Clause Extractor - Test Commands$(NC)'
@echo ''
@echo 'Usage:'
@echo ' make $(GREEN)<target>$(NC)'
@echo ''
@echo 'Targets:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}'
install-test: ## Install test dependencies
@echo '$(BLUE)Installing test dependencies...$(NC)'
pip install -r tests/requirements.txt
@echo '$(GREEN)Test dependencies installed!$(NC)'
test: ## Run all tests
@echo '$(BLUE)Running all tests...$(NC)'
pytest
test-unit: ## Run unit tests only (no database required)
@echo '$(BLUE)Running unit tests...$(NC)'
pytest -m unit -v
test-integration: ## Run integration tests (requires database)
@echo '$(BLUE)Running integration tests...$(NC)'
pytest -m integration -v
test-smoke: ## Run quick smoke tests
@echo '$(BLUE)Running smoke tests...$(NC)'
pytest -m smoke -v
test-cov: ## Run tests with coverage report
@echo '$(BLUE)Running tests with coverage...$(NC)'
pytest --cov=dbase --cov-report=html --cov-report=term
@echo '$(GREEN)Coverage report generated in htmlcov/index.html$(NC)'
test-cov-term: ## Run tests with terminal coverage report
@echo '$(BLUE)Running tests with coverage...$(NC)'
pytest --cov=dbase --cov-report=term-missing
test-fast: ## Run tests in parallel (requires pytest-xdist)
@echo '$(BLUE)Running tests in parallel...$(NC)'
pytest -n auto
test-all: ## Run comprehensive test suite with coverage
@echo '$(BLUE)Running comprehensive test suite...$(NC)'
pytest -v --cov=dbase --cov-report=html --cov-report=term-missing
@echo '$(GREEN)All tests complete!$(NC)'
test-verbose: ## Run tests with maximum verbosity
@echo '$(BLUE)Running tests with verbose output...$(NC)'
pytest -vv -s --tb=long
test-failed: ## Re-run only failed tests from last run
@echo '$(BLUE)Re-running failed tests...$(NC)'
pytest --lf -v
test-debug: ## Run tests with debugger on failure
@echo '$(BLUE)Running tests with debugger...$(NC)'
pytest --pdb
test-models: ## Run model tests only
@echo '$(BLUE)Running model tests...$(NC)'
pytest tests/test_models.py -v
test-repo: ## Run repository integration tests
@echo '$(BLUE)Running repository tests...$(NC)'
pytest tests/test_repository_integration.py -v
test-connection: ## Run connection and config tests
@echo '$(BLUE)Running connection tests...$(NC)'
pytest tests/test_connection_config.py -v
test-watch: ## Run tests in watch mode (requires pytest-watch)
@echo '$(BLUE)Running tests in watch mode...$(NC)'
@command -v ptw >/dev/null 2>&1 || { echo "$(RED)pytest-watch not installed. Run: pip install pytest-watch$(NC)"; exit 1; }
ptw
clean: ## Remove test artifacts and cache
@echo '$(BLUE)Cleaning test artifacts...$(NC)'
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type d -name .pytest_cache -exec rm -rf {} + 2>/dev/null || true
find . -type f -name '*.pyc' -delete
rm -rf htmlcov/
rm -f .coverage
rm -rf .eggs/
rm -rf *.egg-info/
@echo '$(GREEN)Clean complete!$(NC)'
check-db: ## Check if PostgreSQL is running
@echo '$(BLUE)Checking PostgreSQL status...$(NC)'
@if pg_isready -q; then \
echo '$(GREEN)PostgreSQL is running$(NC)'; \
else \
echo '$(RED)PostgreSQL is not running. Start with: brew services start postgresql@14$(NC)'; \
exit 1; \
fi
lint: ## Run ruff linting
@echo '$(BLUE)Running ruff...$(NC)'
ruff check contractex/ tests/
@echo '$(GREEN)Linting passed!$(NC)'
format: ## Format code with black
@echo '$(BLUE)Formatting with black...$(NC)'
black contractex/ tests/
@echo '$(GREEN)Formatting done!$(NC)'
format-check: ## Check formatting without modifying files
@echo '$(BLUE)Checking black formatting...$(NC)'
black --check contractex/ tests/
@echo '$(GREEN)Format check passed!$(NC)'
type-check: ## Run mypy type checking
@echo '$(BLUE)Running mypy...$(NC)'
python3 -m mypy contractex/
@echo '$(GREEN)Type check passed!$(NC)'
qa: format-check lint type-check ## Run all quality checks (format + lint + types)
@echo '$(GREEN)All QA checks passed!$(NC)'
pre-release: qa test-unit ## Full pre-release gate: QA checks + unit tests
@echo '$(GREEN)Pre-release checks complete — safe to release!$(NC)'
stats: ## Show test statistics
@echo '$(BLUE)Test Statistics$(NC)'
@echo ''
@echo 'Total tests:'
@pytest --collect-only -q | tail -n 1
@echo ''
@echo 'Tests by marker:'
@echo -n ' Unit tests: '
@pytest --collect-only -q -m unit 2>/dev/null | tail -n 1 || echo '0'
@echo -n ' Integration tests: '
@pytest --collect-only -q -m integration 2>/dev/null | tail -n 1 || echo '0'
@echo -n ' Smoke tests: '
@pytest --collect-only -q -m smoke 2>/dev/null | tail -n 1 || echo '0'
ci: check-db test-smoke test-unit test-integration ## Run full CI test suite
@echo '$(GREEN)CI test suite complete!$(NC)'
.DEFAULT_GOAL := help