-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathtest.mk
More file actions
255 lines (220 loc) · 7.51 KB
/
test.mk
File metadata and controls
255 lines (220 loc) · 7.51 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
PHONY_TARGETS += test
# Allow duplicate symbols from libkrun.a (contains Rust stdlib symbols).
# This is needed when krun feature is enabled for tests.
export RUSTFLAGS := -C link-arg=-Wl,--allow-multiple-definition
# Default test target runs only changed components.
test:
@$(MAKE) test:changed
# Smart test: only test components with changes, fall back to full matrix.
test\:changed:
ifeq ($(CHANGED_COMPONENTS),)
@echo "📋 No changed components detected — skipping tests."
@echo " (Use 'make test:all' to run the full test matrix)"
else
@echo "📋 Changed components: $(CHANGED_COMPONENTS)"
@echo ""
@$(foreach comp,$(sort $(CHANGED_COMPONENTS)), \
$(MAKE) test:changed:$(comp) && \
) true
@echo ""
@echo "✅ All changed-component tests passed"
endif
# Per-component test dispatch targets (map component tag → existing test targets).
test\:changed\:rust:
@$(MAKE) test:unit:rust
@$(MAKE) test:integration:rust
test\:changed\:server:
@$(MAKE) test:unit:server
test\:changed\:cli:
@$(MAKE) test:integration:cli
test\:changed\:ffi:
@$(MAKE) test:unit:ffi
test\:changed\:python:
@$(MAKE) test:all:python
test\:changed\:node:
@$(MAKE) test:all:node
test\:changed\:c:
@$(MAKE) test:unit:c
@$(MAKE) test:integration:c
test\:changed\:go:
@$(MAKE) test:unit:go
# Full matrix: all unit suites + all integration suites.
test\:all:
@echo "📋 Running full test matrix (unit → integration)"
@echo ""
$(MAKE) test:unit
@echo ""
$(MAKE) test:integration
@echo ""
@echo "✅ All tests passed (full matrix)"
# Unit matrix.
test\:unit:
@echo "── Unit tests (core, sdk) ──"
@echo ""
$(MAKE) test:unit:core
@echo ""
$(MAKE) test:unit:sdk
@echo ""
@echo "✅ Unit test matrix passed"
# Integration matrix.
test\:integration:
@echo "── Integration tests (core, sdk) ──"
@echo ""
$(MAKE) test:integration:core
@echo ""
$(MAKE) test:integration:sdk
@echo ""
@echo "✅ Integration test matrix passed"
# Core unit suites: Rust unit + FFI unit.
test\:unit\:core:
@echo "── Core unit suites (rust, ffi) ──"
@echo ""
$(MAKE) test:unit:rust
@echo ""
$(MAKE) test:unit:ffi
# Core integration suites: Rust integration + CLI integration.
test\:integration\:core:
@echo "── Core integration suites (rust, cli) ──"
@echo ""
$(MAKE) test:integration:rust
@echo ""
$(MAKE) test:integration:cli
# SDK unit suites: Python unit + Node unit + C unit + Go unit.
test\:unit\:sdk:
@echo "── SDK unit suites (python, node, c, go) ──"
@echo ""
$(MAKE) test:unit:python
@echo ""
$(MAKE) test:unit:node
@echo ""
$(MAKE) test:unit:c
@echo ""
$(MAKE) test:unit:go
# SDK integration suites: Python integration + Node integration + C SDK test suite.
test\:integration\:sdk:
@echo "── SDK integration suites (python, node, c) ──"
@echo ""
$(MAKE) test:integration:python
@echo ""
$(MAKE) test:integration:node
@echo ""
$(MAKE) test:integration:c
# Rust unit tests (parallel via nextest, fallback to serial cargo test).
# --no-default-features disables gvproxy to avoid Go runtime link issues.
test\:unit\:rust:
@echo "🧪 Running Rust unit tests..."
@if command -v cargo-nextest >/dev/null 2>&1; then \
cargo nextest run -p boxlite --no-default-features --lib; \
cargo nextest run -p boxlite-shared --lib; \
cargo nextest run -p boxlite-server --lib; \
else \
cargo test -p boxlite --no-default-features --lib -- --test-threads=1; \
cargo test -p boxlite-shared --lib -- --test-threads=1; \
cargo test -p boxlite-server --lib -- --test-threads=1; \
fi
# BoxLite server unit tests.
test\:unit\:server:
@echo "🧪 Running boxlite-server unit tests..."
@if command -v cargo-nextest >/dev/null 2>&1; then \
cargo nextest run -p boxlite-server; \
else \
cargo test -p boxlite-server; \
fi
# Pre-warm Rust integration test image cache (internal helper, still callable).
test\:warm-cache\:rust: runtime\:debug
@echo "🔥 Warming Rust integration test image cache..."
@mkdir -p /tmp/boxlite-test
@./target/debug/boxlite --home /tmp/boxlite-test \
--registry docker.m.daocloud.io \
--registry docker.xuanyuan.me \
--registry docker.1ms.run \
--registry docker.io \
pull alpine:latest 2>/dev/null || \
echo " ⚠️ Pre-warm skipped (pull failed, tests will pull on-demand)"
@echo "✅ Rust integration image cache ready"
# Rust integration tests (requires VM environment).
# Pass FILTER=<pattern> to run a subset, e.g. make test:integration:rust FILTER=copy
test\:integration\:rust: runtime\:debug test\:warm-cache\:rust
@echo "🧪 Running Rust integration tests (requires VM)..."
@if command -v cargo-nextest >/dev/null 2>&1; then \
cargo nextest run -p boxlite --features krun,gvproxy --test '*' --no-fail-fast --profile vm \
$(if $(FILTER),-E 'test(~$(FILTER))',); \
else \
cargo test -p boxlite --features krun,gvproxy --test '*' --no-fail-fast -- --test-threads=1 --nocapture \
$(if $(FILTER),$(FILTER),); \
fi
# BoxLite FFI unit tests.
test\:unit\:ffi:
@echo "🧪 Running BoxLite FFI unit tests..."
@if command -v cargo-nextest >/dev/null 2>&1; then \
cargo nextest run -p boxlite-ffi; \
else \
cargo test -p boxlite-ffi; \
fi
# CLI integration tests.
# Pass FILTER=<pattern> to run a subset.
test\:integration\:cli: runtime\:debug
@echo "🧪 Running CLI integration tests..."
@if command -v cargo-nextest >/dev/null 2>&1; then \
cargo nextest run -p boxlite-cli --tests --profile vm --no-fail-fast \
$(if $(FILTER),-E 'test($(FILTER))',); \
else \
cargo test -p boxlite-cli --tests --no-fail-fast -- --test-threads=4 \
$(if $(FILTER),$(FILTER),); \
fi
# Python SDK unit tests.
test\:unit\:python: _ensure-python-deps
@echo "🧪 Running Python SDK unit tests..."
@. .venv/bin/activate && cd sdks/python && python -m pytest tests/ -v -m "not integration"
# Python SDK integration tests.
test\:integration\:python:
@$(MAKE) dev:python
@echo "🧪 Running Python SDK integration tests..."
@BOXLITE_HOME=$$(mktemp -d /tmp/boxlite-test-python-XXXXXX) && \
trap "rm -rf $$BOXLITE_HOME" EXIT && \
. .venv/bin/activate && cd sdks/python && BOXLITE_HOME=$$BOXLITE_HOME python -m pytest tests/ -v -m "integration"
# Python SDK full suite.
test\:all\:python:
@$(MAKE) test:unit:python
@$(MAKE) test:integration:python
# Node.js SDK unit tests.
test\:unit\:node: _ensure-node-deps
@echo "🧪 Running Node.js SDK unit tests..."
@cd sdks/node && npm test
# Node.js SDK integration tests (requires VM environment).
test\:integration\:node:
@$(MAKE) dev:node
@echo "🧪 Running Node.js SDK integration tests (requires VM)..."
@cd sdks/node && npm run test:integration
# Node.js SDK full suite.
test\:all\:node:
@$(MAKE) test:unit:node
@$(MAKE) test:integration:node
# C SDK unit tests (no VM required).
test\:unit\:c:
@echo "🧪 Running C SDK unit tests..."
@$(MAKE) dev:c
@mkdir -p sdks/c/tests/build
@cd sdks/c/tests/build && cmake ..
@cd sdks/c/tests/build && cmake --build . -j
@cd sdks/c/tests/build && ctest --verbose --output-on-failure -L unit
# C SDK integration tests (requires VM environment).
test\:integration\:c:
@echo "🧪 Running C SDK integration tests (requires VM)..."
@$(MAKE) dev:c
@mkdir -p sdks/c/tests/build
@cd sdks/c/tests/build && cmake ..
@cd sdks/c/tests/build && cmake --build . -j
@cd sdks/c/tests/build && ctest --verbose --output-on-failure -L integration
# C SDK full suite.
test\:all\:c:
@$(MAKE) test:unit:c
@$(MAKE) test:integration:c
# Go SDK unit tests.
test\:unit\:go:
@echo "🧪 Running Go SDK unit tests..."
@$(MAKE) dev:go
@cd sdks/go && go test -tags boxlite_dev -v ./...
# Go SDK full suite.
test\:all\:go:
@$(MAKE) test:unit:go