diff --git a/util/collect_coverage/collect_coverage.rs b/util/collect_coverage/collect_coverage.rs index 7aba667885..4052fe407c 100644 --- a/util/collect_coverage/collect_coverage.rs +++ b/util/collect_coverage/collect_coverage.rs @@ -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 @@ -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 @@ -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: {}",