Code coverage (#529)

Adds `make coverage` (cargo-llvm-cov over the full workspace including
revive-llvm-builder), a new "Code coverage" book chapter that briefly
explains how to run it, and a PR workflow that runs coverage and
comments on the PR (it updates the same comment if it already exists)
when the `measure code coverage` label is applied (see e.g. [this
comment](https://github.com/paritytech/revive/pull/529#issuecomment-4966136441)).

Building instrumented LLVM and generating an LLVM C++ coverage report is
also possible, see accompanying [PR description
#575](https://github.com/paritytech/revive/pull/575) for more details.

---------

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: xermicus <bigcyrill@hotmail.com>
Co-authored-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Co-authored-by: xermicus <cyrill@parity.io>
Co-authored-by: elle-j <linnea@parity.io>
Co-authored-by: LJ <81748770+elle-j@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-07-16 14:48:44 +02:00
1 parent ca3c770228
commit ed95ffbdfe
40 files changed
+882 -123

No files matched your search

+14 -6
View File
@@ -8,7 +8,8 @@ use std::path::Path;
use std::process::Command;
/// The build options shared by all platforms.
pub const SHARED_BUILD_OPTS: [&str; 21] = [
/// `LLVM_ENABLE_ZLIB` is emitted by [`shared_build_opts_coverage`].
pub const SHARED_BUILD_OPTS: [&str; 20] = [
"-DPACKAGE_VENDOR='Parity Technologies'",
"-DCMAKE_BUILD_WITH_INSTALL_RPATH=1",
"-DLLVM_BUILD_DOCS='Off'",
@@ -18,7 +19,6 @@ pub const SHARED_BUILD_OPTS: [&str; 21] = [
"-DLLVM_ENABLE_DOXYGEN='Off'",
"-DLLVM_ENABLE_SPHINX='Off'",
"-DLLVM_ENABLE_OCAMLDOC='Off'",
"-DLLVM_ENABLE_ZLIB='Off'",
"-DLLVM_ENABLE_ZSTD='Off'",
"-DLLVM_ENABLE_LIBXML2='Off'",
"-DLLVM_ENABLE_BINDINGS='Off'",
@@ -188,10 +188,18 @@ pub fn shared_build_opts_tests(enabled: bool) -> Vec<String> {
/// The code coverage build options shared by all platforms.
pub fn shared_build_opts_coverage(enabled: bool) -> Vec<String> {
vec![format!(
"-DLLVM_BUILD_INSTRUMENTED_COVERAGE='{}'",
if enabled { "On" } else { "Off" },
)]
vec![
format!(
"-DLLVM_BUILD_INSTRUMENTED_COVERAGE='{}'",
if enabled { "On" } else { "Off" },
),
// zlib is required to be able to read the compressed profiles that
// instrumented resolc binaries emit.
format!(
"-DLLVM_ENABLE_ZLIB='{}'",
if enabled { "FORCE_ON" } else { "Off" },
),
]
}
/// Use of compiler cache (ccache) to speed up the build process.