taiki-e / cargo-llvm-cov

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

`cargo llvm-cov nexttest-archive` does not work with the `--cargo-profile` flag of nextest #348

Closed weiznich closed 4 months ago

weiznich commented 4 months ago

I've run the following commands:

cargo llvm-cov nextest-archive --cargo-profile test-jenkins --archive-file tests.tar.zst
cargo llvm-cov nextest --archive-file tests.tar.zst

while having a custom cargo profile test-jenkins that just disable incremental compilation.

This fails after running the tests with the following output:

warning: not found object files (searched directories: /src/target/llvm-cov-target/target/debug); this may occur if show-env subcommand is used incorrectly (see docs or other warnings), or unsupported commands such as nextest archive are used
No filenames specified!
error: failed to generate report: process didn't exit successfully: `/usr/local/rustup/toolchains/1.75.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-cov report -instr-profile=/src/target/llvm-cov-target/src.profdata -ignore-filename-regex '/rustc/([0-9a-f]+|[0-9]+\.[0-9]+\.[0-9]+)/|^/src(/.*)?/(tests|examples|benches)/|^/src/target/llvm\-cov\-target($|/)|^/usr/local/cargo/(registry|git)/|^/usr/local/rustup/toolchains($|/)'` (exit status: 1)

Likely that's related to the fact that it search in the wrong path for the mentioned object files. I would expect them in /src/target/llvm-cov-target/target/test-jenkins instead. It works fine as long as I don't specify a profile at all.

taiki-e commented 4 months ago

This is a similar case of https://github.com/taiki-e/cargo-llvm-cov/issues/334.

The same flags (--cargo-profile) need to be passed to both cargo llvm-cov nextest-archive and cargo llvm-cov nextest --archive-file, but cargo-llvm-cov is not working because it propagates them to cargo nextest .. --extract-to.

error: the argument '--extract-to <DIR>' cannot be used with:

Ideally I would like to embed information about the flags passed to cargo llvm-cov nextest-archive to the archive created by nextest-archive to eliminate the need to pass the same flags to cargo llvm-cov nextest --archive-file, but I don't know if nextest supports that.