Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
90 lines (77 loc) · 2.95 KB
/
Copy pathMakefile
File metadata and controls
90 lines (77 loc) · 2.95 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
.PHONY: default
default:
cargo build
.PHONY: clean
clean:
rm -rf Cargo.lock target/ freestanding/Cargo.lock freestanding/target/
.PHONY: test
test:
cargo test --lib
# TEMPORARY, remove with the feature. Lib-only: the strict integration tests reject what it allows.
cargo test --lib --features __allow_omitted_auth_method
# `--tests` rather than `--test '*'`: the glob counts as explicit target selection,
# so Cargo hard-errors on a target whose `required-features` are unmet (the live
# network suites). Bulk selection skips those instead.
set -eu; \
for feature_set in '__integration' 'websockets,__integration'; do \
cargo test --features "$$feature_set" --tests; \
done
# Live tests against a real MQTT server. BROKER selects which broker implementation gets
# provisioned -- the suite itself is server-agnostic. Each broker directory exposes
# up.sh/down.sh, so a broker that isn't a container (AIO MQ needs a k3d cluster)
# plugs in the same way.
# Deliberately not part of `test`: these need a server running.
BROKER ?= mosquitto
# Extra cargo features for the network suite, e.g. __allow_omitted_auth_method for aio-mq-1.6.1.
FEATURES ?=
.PHONY: network-test
network-test:
tests/network/fixtures/up.sh $(BROKER)
# Teardown shares one shell with the test run so it happens even on failure.
set -u; \
MQTT_SERVER=$(BROKER) cargo test --features "__network,websockets $(FEATURES)" --test network; \
status=$$?; \
tests/network/fixtures/down.sh $(BROKER); \
exit $$status
.PHONY: coverage
coverage:
cargo llvm-cov clean --workspace
cargo llvm-cov --no-report --features websockets,__integration --tests
cargo llvm-cov report --html
cargo llvm-cov report --summary-only
.PHONY: network-coverage
network-coverage:
cargo llvm-cov clean --workspace
tests/network/fixtures/up.sh $(BROKER)
# Run every test with one feature set so LLVM coverage maps stay compatible.
set -u; \
MQTT_SERVER=$(BROKER) cargo llvm-cov --no-report \
--features websockets,__integration,__network \
--tests; \
test_status=$$?; \
tests/network/fixtures/down.sh $(BROKER); \
down_status=$$?; \
if test "$$test_status" -ne 0; then exit "$$test_status"; fi; \
exit "$$down_status"
cargo llvm-cov report --html
cargo llvm-cov report --summary-only
.PHONY: check
check:
cargo fmt --verbose --all --check
# `__network` is enabled here (and nowhere in `test`) so the live network suites
# are compiled and linted on every check, without ever being run.
set -eu; \
for feature_set in '__integration,__network' 'websockets,__integration,__network'; do \
cargo clippy \
--features "$$feature_set" \
--tests \
--examples \
-- \
--deny=warnings; \
done
cargo machete
# Advisories are deliberately excluded here: they depend on the RustSec
# database (which updates independently of our code) and so belong in the
# scheduled `nightly` workflow, not the deterministic PR gate. bans,
# licenses, and sources only change when our dependencies do.
cargo deny check bans licenses sources