From 6113483363fbd009f4bb01a560cffdf7cdf7d7f7 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Thu, 19 Oct 2023 23:43:10 +0000 Subject: [PATCH] docs: add notes on collecting coverage data from in-tree tests Signed-off-by: Wei Liu --- docs/coverage.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/coverage.md b/docs/coverage.md index f95181c86..38fce82d9 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -53,3 +53,29 @@ grcov . --binary-path ./target/x86_64-unknown-linux-gnu/release -s . -t html --b You can then open the `index.html` file under coverage-html-output to see the results. + +## Notes on running the in-tree integration tests and unit tests + +Please set RUSTFLAGS the same way while invoking `dev_cli.sh`. The script will +pass RUSTFLAGS to the container. + +Since the `profraw` files are generated from within the container, the file +paths embedded in the data files are going to be different. It is easier to do +the data processing from within the container if you don't want to fight the +tool chain. + +```shell +# Get a shell +./scripts/dev_cli.sh shell + +# Install llvm-tools-preview for llvm-profdata +rustup component add llvm-tools-preview +# Merge data files by using the following command +find . -name '*.profraw' -exec `rustc --print sysroot`/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -sparse {} -o coverage.profdata \; + +# As of writing, the container has Rust 1.67.1. It is too old for grcov. +rustup install stable +cargo +stable install grcov +# Run grcov as usual +grcov . --binary-path ./target/x86_64-unknown-linux-gnu/release -s . -t html --branch --ignore-not-existing -o coverage-html-output/ +```