-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmakefile
More file actions
230 lines (194 loc) · 8.76 KB
/
makefile
File metadata and controls
230 lines (194 loc) · 8.76 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
setup:
make install-tests
make install-jupyter
make setup-pre-commit
make install-docs
# 安装必要的代码检查工具
# black: https://github.com/psf/black
# flake8: https://github.com/pycqa/flake8
# isort: https://github.com/PyCQA/isort
# nbstripout: https://github.com/kynan/nbstripout
# pydocstyle: https://github.com/PyCQA/pydocstyle
# pre-commit-hooks: https://github.com/pre-commit/pre-commit-hooks
setup-dependencies:
uv sync
setup-pre-commit:
uv add --dev flake8 isort nbstripout pydocstyle pre-commit-hooks interrogate sourcery mypy bandit black pylint ruff
install-jupyter:
uv add --dev ipykernel jupyterlab jupyterlab-execute-time
install-tests:
uv add hydra-core
uv add --dev pytest allure-pytest pytest-cov pytest-clarity pytest-sugar
# https://timvink.github.io/mkdocs-git-authors-plugin/index.html
install-docs:
uv add --group docs mkdocs mkdocs-material mkdocs-git-revision-date-localized-plugin mkdocs-minify-plugin mkdocs-redirects mkdocs-awesome-pages-plugin mkdocs-git-authors-plugin 'mkdocstrings[python]' mkdocs-bibtex mkdocs-macros-plugin mkdocs-jupyter mkdocs-callouts mkdocs-glightbox pymdown-extensions
# =============================================================================
# 分层测试命令
# =============================================================================
# 基础功能测试 - 第1层:验证核心类能正常创建和基本操作
test-foundation:
@echo "🧪 Running Foundation Tests (Layer 1)..."
uv run pytest tests/foundation/ -v --tb=short --cov=abses --cov-report=term-missing
# 用户场景测试 - 第2层:基于实际使用场景的测试
test-scenarios:
@echo "🎯 Running Scenario Tests (Layer 2)..."
uv run pytest tests/scenarios/ -v --tb=short --cov=abses --cov-report=term-missing
# 向后兼容性测试 - 保护现有功能
test-compatibility:
@echo "🔄 Running Backward Compatibility Tests..."
uv run pytest tests/test_backward_compatibility.py -v --tb=short
# 向后兼容性测试(包含所有兼容性测试)
test-compatibility-all:
@echo "🔄 Running All Backward Compatibility Tests..."
uv run pytest tests/test_*compatibility*.py -v --tb=short
# 快速测试 - 只运行基础测试,用于开发时快速验证
test-quick:
@echo "⚡ Running Quick Tests (Foundation only)..."
uv run pytest tests/foundation/ -v --tb=short
# 完整测试 - 运行所有分层测试(只包含通过的测试)
test-layered:
@echo "🏗️ Running All Layered Tests..."
@echo "Layer 1: Foundation Tests"
uv run pytest tests/foundation/ -v --tb=short --cov=abses --cov-report=term-missing
@echo "Layer 2: Scenario Tests"
uv run pytest tests/scenarios/ -v --tb=short --cov=abses --cov-report=term-missing
@echo "✅ All layered tests completed successfully!"
# 测试覆盖率报告
test-coverage:
@echo "📊 Generating Test Coverage Report..."
uv run pytest tests/foundation/ tests/scenarios/ --cov=abses --cov-report=html --cov-report=term-missing
@echo "Coverage report generated in htmlcov/index.html"
# 开发测试 - 快速验证,不生成覆盖率报告
test-dev:
@echo "🔧 Running Development Tests..."
uv run pytest tests/foundation/ tests/scenarios/ -v --tb=short -x
# 测试特定功能
test-agents:
@echo "🤖 Testing Agent-related functionality..."
uv run pytest tests/ -k "agent" -v --tb=short
test-spatial:
@echo "🗺️ Testing Spatial functionality..."
uv run pytest tests/ -k "spatial or cell or patch" -v --tb=short
test-model:
@echo "🏗️ Testing Model functionality..."
uv run pytest tests/ -k "model" -v --tb=short
# 测试特定模块
test-module:
@echo "🔍 Testing specific module (usage: make test-module MODULE=agents)"
@if [ -z "$(MODULE)" ]; then echo "Please specify MODULE=module_name"; exit 1; fi
uv run pytest tests/ -k "$(MODULE)" -v --tb=short
# 并行测试 - 提高测试速度
test-parallel:
@echo "🚀 Running Tests in Parallel..."
uv run pytest tests/foundation/ tests/scenarios/ -n auto -v --tb=short
# 测试帮助 - 显示所有可用的测试命令
test-help:
@echo "📋 Available Test Commands:"
@echo ""
@echo "🧪 Foundation Tests (Layer 1):"
@echo " make test-foundation - Run foundation tests only"
@echo " make test-quick - Quick test (foundation only)"
@echo ""
@echo "🎯 Scenario Tests (Layer 2):"
@echo " make test-scenarios - Run scenario tests only"
@echo ""
@echo "🔄 Compatibility Tests:"
@echo " make test-compatibility - Run backward compatibility tests"
@echo " make test-compatibility-all - Run all compatibility tests"
@echo ""
@echo "🏗️ Complete Test Suites:"
@echo " make test-layered - Run all layered tests (stable)"
@echo " make test-dev - Development tests (fast, stop on first failure)"
@echo " make test - Run all tests (original)"
@echo " make test-all - Run all tests including notebooks and tox"
@echo " make test-tox - Run only multi-version tests with tox"
@echo ""
@echo "🔍 Feature-Specific Tests:"
@echo " make test-agents - Test agent-related functionality"
@echo " make test-spatial - Test spatial functionality"
@echo " make test-model - Test model functionality"
@echo ""
@echo "🚀 Performance & Coverage:"
@echo " make test-parallel - Run tests in parallel"
@echo " make test-coverage - Generate coverage report"
@echo ""
@echo "📓 Notebook Tests:"
@echo " make test-notebooks - Test all tutorial notebooks"
@echo " make test-notebook - Test all tutorial notebooks (same as test-notebooks)"
@echo " make test-notebook NB=path - Test a specific notebook"
@echo " make test-all-notebooks - Test all notebooks (including examples)"
@echo ""
@echo "🔍 Specific Testing:"
@echo " make test-module MODULE=agents - Test specific module"
@echo ""
@echo "📊 Reports:"
@echo " make report - View allure test report"
# 测试清理
test-clean:
@echo "🧹 Cleaning test artifacts..."
rm -rf .pytest_cache/
rm -rf htmlcov/
rm -rf .coverage*
rm -rf tmp/allure_results/
@echo "Test artifacts cleaned!"
# 测试安装 - 安装测试相关依赖
install-test-tools:
@echo "📦 Installing test tools..."
uv add --dev pytest-xdist pytest-benchmark pytest-mock nbmake
@echo "Test tools installed!"
# Jupyter notebook 测试 - 使用 nbmake 测试所有教程 notebooks
test-notebooks:
@echo "📓 Running All Jupyter Notebook Tests..."
uv run pytest --nbmake docs/tutorial/**/*.ipynb -v --tb=short
# 测试特定 notebook
test-notebook:
@if [ -z "$(NB)" ]; then \
echo "📓 No notebook specified, running all tutorial notebooks..."; \
uv run pytest --nbmake docs/tutorial/**/*.ipynb -v --tb=short; \
else \
echo "📓 Testing specific notebook: $(NB)"; \
uv run pytest --nbmake $(NB) -v --tb=short; \
fi
# =============================================================================
# 原有测试命令(保持兼容性)
# =============================================================================
# 完整测试套件(包含所有测试)
test:
uv run pytest -vs --clean-alluredir --alluredir tmp/allure_results --cov=abses --no-cov-on-fail
# 多版本测试(包含 notebook 测试和 tox)
test-all:
@echo "🧪 Running Complete Test Suite (Including Notebooks and Multi-version)..."
@echo "Running standard tests..."
uv run pytest tests/ -vs --clean-alluredir --alluredir tmp/allure_results --cov=abses --no-cov-on-fail
@echo "Installing docs dependencies for notebook tests..."
@uv sync --group docs || echo "⚠️ Failed to install docs dependencies"
@echo "Running notebook tests..."
uv run pytest --nbmake docs/tutorial/**/*.ipynb -v --tb=short || echo "⚠️ Some notebook tests may have failed (this is acceptable for documentation notebooks)"
@echo "Running multi-version tests with tox..."
@echo "⚠️ Note: tox may have issues with uv-managed Python environments. If it fails, consider using system Python for tox."
tox -p auto || echo "⚠️ Multi-version tests completed with warnings"
@echo "✅ All tests completed!"
# 仅运行 tox 多版本测试
test-tox:
@echo "🔄 Running Multi-version Tests with Tox..."
@echo "⚠️ Note: tox uses system Python interpreters. Make sure python3.11, python3.12, python3.13 are available in PATH."
tox -p auto
# 仅运行 notebook 测试(包括所有 ipynb 文件)
test-all-notebooks:
@echo "📓 Running All Notebook Tests (including examples)..."
uv run pytest --nbmake "**/*.ipynb" -v --tb=short --ignore=site
report:
uv run allure serve tmp/allure_results
jupyter:
uv run jupyter lab
diagram:
pyreverse -o png -p ABSESpy abses
mv *.png img/.
show_logs:
find . -type f -name "*.log"
clean_logs:
./remove-logs.sh
rm_log:
echo "Removing .coverage and *.log files..."
ls .coverage* 1>/dev/null 2>&1 && rm .coverage* || true
ls *.log 1>/dev/null 2>&1 && rm *.log || true