-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(coverage
): caching for coverage
#9366
base: master
Are you sure you want to change the base?
Conversation
coverage
): write coverage artifacts to separate dircoverage
): separate dir + caching for coverage artifacts
did you test that coverage is collected correctly even after multiple different builds? it doesn't look like we account for different |
Update: In the previous implementation, we always recompiled the sources when running However, now that we have enabled caching, we cannot assume that Issue demonstrated by test here: e90a354 Next step to tackle this is to make coverage smarter by accounting for |
* fix: use `SourceIdentifier` in SourceFiles mapping * fix(`coverage`): use `SourceIdentifier` in analysis and report. * fix * nit * nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should get rid of indexing by compiler version which was a workaround before we had build_id
, including its usage in ContractId
this also does not correctly handle build_ids when processing hitmaps
when we identify a bytecode, we receipt ArtifactId
which contains a build_id
we should respect vs just the source_id
coverage
): separate dir + caching for coverage artifactscoverage
): caching for coverage
coverage
): caching for coveragecoverage
): caching for coverage
.and_then(|items| items.get_mut(anchor.item_id)) | ||
.get_mut(&contract_id.source_id) | ||
.and_then(|items| { | ||
let scaled_item_id = anchor.item_id % items.len(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't look correct. right now items are keyed by the source_id they are from but this tries to get it by the source id of the contract where anchor was found
/// All item anchors for the codebase, keyed by their contract ID. | ||
pub anchors: HashMap<ContractId, (Vec<ItemAnchor>, Vec<ItemAnchor>)>, | ||
/// All the bytecode hits for the codebase. | ||
pub bytecode_hits: HashMap<ContractId, HitMap>, | ||
/// The bytecode -> source mappings. | ||
pub source_maps: HashMap<ContractId, (SourceMap, SourceMap)>, | ||
/// Anchor Item ID by source ID | ||
pub item_ids_by_source_id: HashMap<SourceIdentifier, Vec<usize>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems unused?
/// All coverage items for the codebase, keyed by the compiler version. | ||
pub items: HashMap<Version, Vec<CoverageItem>>, | ||
pub items: HashMap<SourceIdentifier, Vec<CoverageItem>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should now be a Vec<CoverageItem>
I guess given that we no longer have a version-level separation
crates/forge/bin/cmd/coverage.rs
Outdated
} | ||
|
||
let anchors = artifacts | ||
.par_iter() | ||
.filter(|artifact| sources.sources.contains_key(&artifact.contract_id.source_id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.filter(|artifact| sources.sources.contains_key(&artifact.contract_id.source_id)) |
this should not be needed anymore
Motivation
Closes: Separate directory for artifacts generated by coverage.
Closes: Enable caching for coverage
Addresses #8840 (comment).
Somewhat addresses #8904 + #8889 - by enabling cache and avoiding recompilation
Solution
out/coverage
andout/coverage/build-info
.cache/coverage/