Repository navigation
Expand file tree
/
Copy pathcoverage.sh
More file actions
executable file
·56 lines (40 loc) · 1.82 KB
/
Copy pathcoverage.sh
File metadata and controls
executable file
·56 lines (40 loc) · 1.82 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
#!/bin/bash
set -e
# Prerequisites:
# rustup component add llvm-tools-preview
# cargo install rustfilt
# cargo install grcov@0.5.1
# or download grcov from https://github.com/mozilla/grcov/releases
export RUSTC_BOOTSTRAP=1
# Create the directory for coverage reports
mkdir -p target/coverage
# Clean any previous coverage data
rm -rf target/coverage/*
# Clean previous build artifacts to ensure coverage instrumentation is applied
cargo clean
rm -f *.profraw
export RUSTFLAGS="-Cinstrument-coverage"
# Build the project with coverage instrumentation
cargo build --verbose
# Set environment variables for coverage
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-C instrument-coverage -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Cpanic=abort"
export LLVM_PROFILE_FILE="target/coverage/coverage-%p-%m.profraw"
# Run tests with coverage instrumentation
cargo test --no-fail-fast --verbose
# List all the profraw files to verify they were created
echo "Generated profraw files:"
# ls -la target/coverage/
# Generate coverage report
# target/coverage
grcov . --binary-path ./target/debug -s . -t html --branch --ignore-not-existing --ignore "/*" --ignore "target/*" --ignore "tests/*" --ignore "examples/*" -o target/coverage/html
# Generate a summary report
grcov . --binary-path ./target/debug -s . -t lcov --branch --ignore-not-existing --ignore "/*" --ignore "target/*" --ignore "tests/*" --ignore "examples/*" -o target/coverage/lcov.info
# Print a message with the location of the coverage report
echo "Coverage report generated at target/coverage/html/index.html"
ls -la *.profraw
rm -rf *.profraw
# Start a local web server to view the coverage report
cd target/coverage/html && python3 -m http.server 8080
# open http://localhost:8080/src/yul2ir/index.html