Skip to content
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

fix(coverage): separate dir + caching for coverage artifacts #9366

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
11 changes: 11 additions & 0 deletions crates/forge/bin/cmd/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ impl CoverageArgs {
fn build(&self, config: &Config) -> Result<(Project, ProjectCompileOutput)> {
// Set up the project
let mut project = config.create_project(false, false)?;

// Set a different artifacts path for coverage. `out/coverage`.
// This is done to avoid overwriting the artifacts of the main build that maybe built with
// different optimizer settings or --via-ir. Optimizer settings are disabled for
// coverage builds.
let coverage_artifacts_path = project.artifacts_path().join("coverage");
project.paths.artifacts = coverage_artifacts_path.clone();
project.paths.build_infos = coverage_artifacts_path.join("build-info");
yash-atreya marked this conversation as resolved.
Show resolved Hide resolved

if self.ir_minimum {
// print warning message
sh_warn!("{}", concat!(
Expand Down Expand Up @@ -124,6 +133,8 @@ impl CoverageArgs {
project.settings.solc.via_ir = None;
}

sh_warn!("optimizer settings have been disabled for accurate coverage reports")?;

let output = ProjectCompiler::default()
.compile(&project)?
.with_stripped_file_prefixes(project.root());
Expand Down
Loading