taiki-e / cargo-llvm-cov

Cargo subcommand to easily use LLVM source-based code coverage (-C instrument-coverage).
Apache License 2.0
859 stars 57 forks source link

`cargo build` support in `cargo-llvm-cov` #373

Open psandana opened 2 weeks ago

psandana commented 2 weeks ago

Request This is a request to consider calling cargo build from within cargo-llvm-cov.

Reasoning CI systems are mostly building dev profile and running tests with coverage. As cargo-llvm-cov introduces special setup for tests, dev builds intermediate and final objects cannot be resused by the pipeline, implying recompilation of the whole codebase. This waste time and resources. This is more critical on CI systems, where building can take an order of tens of minutes.

If we could execute cargo build from within cargo-llvm-cov we could reuse dev profile builds for the test execution, saving important time ⌚ and CPU (think greener 🍃!).

I already tried using caching steps for our target folder in our pipeline, but even for that, we require twice the storage to host build dev and cargo llvm-cov test caches.

Solution A solution for this, would make the following call valid:

cargo llvm-cov build

All arguments for cargo build should be available and pass it down to cargo build.

Extra This solution may also work for complex integration tests, which can make use of the binaries generated in special environments (for instance, a micro-services test deployment).

taiki-e commented 2 weeks ago

Unfortunately, the proposed API does not work well because specific environment variables must also be set at runtime.

The way it is currently available for this kind of use case is to use show-env.