Repository navigation
collect: route instrumented builds to target/affected/build/ - #12
Merged
Merged
Conversation
`cargo affected collect` was running `cargo nextest list/run` with RUSTFLAGS=-C instrument-coverage but no isolated --target-dir, so cargo compiled every workspace package — including helper binaries pulled in by `default-members` — into target/debug/ as instrumented artifacts. Those binaries lingered after collect exited, and any later non-coverage `cargo test` that spawned them wrote `default_*.profraw` files to its CWD (LLVM's fallback when LLVM_PROFILE_FILE isn't set). Pass --target-dir target/affected/build/ to all three cargo invocations (initial list, pre-run list, run) so coverage builds stay out of target/debug/. The build dir is persistent — sharing it across collects preserves cargo's incremental cache. Sweep stale build-script profraws on each collect since their bundles aren't useful between runs. Move the build-script LLVM_PROFILE_FILE pattern to the target-dir root (target/affected/build/build-%p-%m.profraw) to mirror cargo-llvm-cov's convention. Setup-scripts that recover the target-dir via dirname(LLVM_PROFILE_FILE) — e.g. worktrunk's helper-binary builder — now resolve to the right place without having to know cargo-affected's specific layout. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cargo affected collectwas runningcargo nextest list/runwithRUSTFLAGS=-C instrument-coveragebut no isolated--target-dir, so cargo compiled every workspace package — including helper binaries pulled in bydefault-members— intotarget/debug/as instrumented artifacts. Those binaries lingered after collect exited, and any later non-coveragecargo testthat spawned them wrotedefault_*.profrawfiles to its CWD (LLVM's fallback whenLLVM_PROFILE_FILEisn't set).Pass
--target-dir target/affected/build/to all three cargo invocations (initial list, pre-run list, run) so coverage builds stay out oftarget/debug/. The build dir is persistent — sharing it across collects preserves cargo's incremental cache. Sweep stale build-script profraws on each collect since they aren't useful between runs.Move the build-script
LLVM_PROFILE_FILEpattern to the target-dir root (target/affected/build/build-%p-%m.profraw) to mirror cargo-llvm-cov's convention. Setup-scripts that recover the target-dir viadirname(LLVM_PROFILE_FILE)— e.g. worktrunk's helper-binary builder — now resolve to the right place without having to know cargo-affected's specific layout.cargo affected run/statusare unchanged: they don't pass--target-dirand don't setRUSTFLAGS, so they keep sharing the user's normaltarget/debug/cache.