#!/bin/bash

set -ex

rustup component add llvm-tools-preview
export RUSTFLAGS="-Cinstrument-coverage"
cargo build
export LLVM_PROFILE_FILE="./target/debug/profraw/coverage-%p-%m.profraw"
cargo test
cargo install grcov
grcov . --binary-path ./target/debug/ -s . -t html --branch --ignore-not-existing -o ./target/debug/coverage/
grcov . --binary-path ./target/debug/ -s . -t cobertura --branch --ignore-not-existing -o ./target/debug/coverage/coverage.xml
cat ./target/debug/coverage/coverage.json
