Skip to content

coverage binary override #3490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions util/collect_coverage/collect_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//! - `ROOT`: Location from where the code coverage collection was invoked.
//! - `RUNFILES_DIR`: Location of the test's runfiles.
//! - `VERBOSE_COVERAGE`: Print debug info from the coverage scripts
//! - `COVERAGE_BINARY`: The binary that should be used for coverage (optional by default uses `TEST_BINARY`)
//!
//! The script looks in $COVERAGE_DIR for the Rust metadata coverage files
//! (profraw) and uses lcov to get the coverage data. The coverage data
Expand Down Expand Up @@ -47,9 +48,11 @@ fn find_metadata_file(execroot: &Path, runfiles_dir: &Path, path: &str) -> PathB
}

fn find_test_binary(execroot: &Path, runfiles_dir: &Path) -> PathBuf {
let bin = env::var("COVERAGE_BINARY").unwrap_or_else(|_| env::var("TEST_BINARY").unwrap());

let test_binary = runfiles_dir
.join(env::var("TEST_WORKSPACE").unwrap())
.join(env::var("TEST_BINARY").unwrap());
.join(&bin);

if !test_binary.exists() {
let configuration = runfiles_dir
Expand All @@ -70,9 +73,7 @@ fn find_test_binary(execroot: &Path, runfiles_dir: &Path) -> PathBuf {
path
});

let test_binary = execroot
.join(configuration)
.join(env::var("TEST_BINARY").unwrap());
let test_binary = execroot.join(configuration).join(&bin);

debug_log!(
"TEST_BINARY is not found in runfiles. Falling back to: {}",
Expand Down