-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (63 loc) · 2.08 KB
/
Makefile
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
.DEFAULT_GOAL := build
fmt:
cargo fmt
.PHONY:fmt
# `rustup component add clippy`
lint:
cargo clippy
.PHONY: lint
build: fmt lint
cargo build
.PHONY: build
release: fmt lint
cargo build --release
.PHONY: release
run: fmt lint
# it requires `cargo-watch` via `make deps`
cargo watch -x 'run' --ignore 'src/tests_integration/*'
.PHONY: run
clean:
cargo clean
.PHONY: clean
doc:
cargo rustdoc
.PHONY: doc
test:
# append `-- --nocapture` to `cargo test` command to show output in console also on success
ENV=testing RUST_BACKTRACE=full cargo test -- --nocapture --test-threads 1
.PHONY: test
test-coverage:
# test coverage documentation https://doc.rust-lang.org/rustc/instrument-coverage.html
# test coverage tutorial https://blog.rng0.io/how-to-do-code-coverage-in-rust
# you need both 'grcov' and 'llvm-tools-preview' to run tests with coverage
rm -rf coverage
mkdir -p coverage/html
# run test instrumenting for code coverage
# append `-- --nocapture` to `cargo test` command to show output in console also on success
ENV=testing RUST_BACKTRACE=full CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='./coverage/cargo-test-%p-%m.profraw' cargo test -- --nocapture --test-threads 1
grcov . --binary-path ./target/debug/ -s . -t html --branch \
--ignore-not-existing \
--ignore "src/tests_integration/*" \
--ignore "target/*" \
--excl-start '^\#\[cfg\(test\)\]' \
--excl-stop '^}' \
-o coverage/html
# if you want, you can emit lcov report or other via -t parameter
# grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore "src/tests/*" -o coverage/tests.lcov
.PHONY: coverage
deps: deps-test
rustup update
rustup component add clippy
rustup component add rustfmt
cargo update
cargo install cargo-watch
.PHONY: deps
deps-ci: deps-test
rustup component add clippy
rustup component add rustfmt
.PHONY: deps-ci
deps-test:
# install mozilla/grcov and llvm-tools-preview to show test code coverage
cargo install grcov
rustup component add llvm-tools-preview
.PHONE: deps-test