-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
67 lines (55 loc) · 2.25 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
CARGO_TARGET_DIR ?= target
COVERAGE_PROFRAW_DIR ?= ${CARGO_TARGET_DIR}/coverage
GRCOV_OUTPUT ?= coverage-report.info
GRCOV_EXCL_START = ^\s*((log::|tracing::)?(trace|debug|info|warn|error)|(debug_)?assert(_eq|_ne|_error_eq))!\($$
GRCOV_EXCL_STOP = ^\s*\)(;)?$$
GRCOV_EXCL_LINE = ^\s*(\})*(\))*(;)*$$|\s*((log::|tracing::)?(trace|debug|info|warn|error)|(debug_)?assert(_eq|_ne|_error_eq))!\(.*\)(;)?$$
.PHONY: test
test:
RUST_LOG=off cargo nextest run --no-fail-fast
.PHONY: clippy
clippy:
cargo clippy --all --all-targets --all-features
.PHONY: bless
bless:
cargo clippy --fix --allow-dirty --allow-staged --all --all-targets --all-features
.PHONY: fmt
fmt:
cargo fmt --all -- --check
coverage-clean:
rm -rf "${CARGO_TARGET_DIR}/*.profraw" "${GRCOV_OUTPUT}" "${GRCOV_OUTPUT:.info=}"
coverage-install-tools:
rustup component add llvm-tools-preview
grcov --version || cargo install --locked grcov
coverage-run-unittests:
mkdir -p "${COVERAGE_PROFRAW_DIR}"
rm -f "${COVERAGE_PROFRAW_DIR}/*.profraw"
RUSTFLAGS="${RUSTFLAGS} -Cinstrument-coverage" \
RUST_LOG=off \
LLVM_PROFILE_FILE="${COVERAGE_PROFRAW_DIR}/unittests-%p-%m.profraw" \
cargo test --all
coverage-collect-data:
grcov "${COVERAGE_PROFRAW_DIR}" --binary-path "${CARGO_TARGET_DIR}/debug/" \
-s . -t lcov --branch --ignore-not-existing \
--ignore "/*" \
--ignore "*/tests/*" \
--ignore "*/tests.rs" \
--excl-br-start "${GRCOV_EXCL_START}" --excl-br-stop "${GRCOV_EXCL_STOP}" \
--excl-start "${GRCOV_EXCL_START}" --excl-stop "${GRCOV_EXCL_STOP}" \
--excl-br-line "${GRCOV_EXCL_LINE}" \
--excl-line "${GRCOV_EXCL_LINE}" \
-o "${GRCOV_OUTPUT}"
coverage-generate-report:
genhtml --ignore-errors inconsistent --ignore-errors corrupt --ignore-errors range --ignore-errors unmapped -o "${GRCOV_OUTPUT:.info=}" "${GRCOV_OUTPUT}"
coverage: coverage-run-unittests coverage-collect-data coverage-generate-report
.PHONY: gen-rpc-doc
gen-rpc-doc:
cargo install fiber-rpc-gen
fiber-rpc-gen ./src/rpc
if grep -q "TODO: add desc" ./src/rpc/README.md; then \
echo "Warning: There are 'TODO: add desc' in src/rpc/README.md, please add documentation comments to resolve them"; \
exit 1; \
fi
.PHONY: check-dirty-rpc-doc
check-dirty-rpc-doc: gen-rpc-doc
git diff --exit-code ./src/rpc/README.md