Debian Codegraph @

ci/coverage.sh

raw symbols SCIP
1 #! /usr/bin/env bash
2
3 # Script to analyze Rust code using grcov.
4 #
5 # Usage: ./code_coverage.sh [open|codecov]
6
7 set -e
8
9 arg1="$1"
10 os=$(uname -s | tr '[:upper:]' '[:lower:]')
11
12 # To use nightly rust: NIGHTLY="+nightly"
13 NIGHTLY=""
14
15 if [ -n "$NIGHTLY" ]; then
16 rustup install nightly
17 fi
18
19 # Set up grcov.
20 rustup component add llvm-tools-preview
21 export RUSTFLAGS="-Cinstrument-coverage"
22 export LLVM_PROFILE_FILE="exacl-%p-%m.profraw"
23 cargo $NIGHTLY install grcov
24
25 # Build & Test
26 cargo $NIGHTLY clean
27 cargo $NIGHTLY test --features serde
28 cargo $NIGHTLY build --features serde
29 ./tests/run_tests.sh
30
31 if [ "$arg1" = "open" ]; then
32 echo "Producing HTML Report locally"
33 grcov . --binary-path ./target/debug/ -s . -t html --branch --ignore-not-existing --ignore "/*" -o ./target/debug/coverage/
34 open target/debug/coverage/src/index.html
35 elif [ "$arg1" = "codecov" ]; then
36 echo "Producing lcov report and uploading it to codecov.io"
37 grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
38 bash <(curl -s https://codecov.io/bash) -f lcov.info -n "$os"
39 fi
40
41 exit 0