taiki-e / cargo-llvm-cov

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

Prepend `target` if no explicit target directory is set #350

Closed weiznich closed 6 months ago

weiznich commented 7 months ago

This commit prepend target to the profile target directory path, if no explicit target is set. This is necessary to allow using a custom --profile flag via cargo llvm-cov report. Without this change I get the following error message:

$ cargo llvm-cov report --profile test-jenkins
warning: not found object files (searched directories: /builds/test-project/target/llvm-cov-target/test-jenkins); this may occur if show-env subcommand is used incorrectly (see docs or other warnings), or unsupported commands are used
No filenames specified!

This can be worked around at the calling site by using target/test-jenkins as profile name. That means calling cargo llvm-cov --profile target/test-jenkins seems to work fine.

weiznich commented 7 months ago

As the CI tests indicate that breaks something else. I would appreciate some pointers how to approach that differently.

taiki-e commented 7 months ago

cx.args.target is about the target triple (e.g., x86_64-apple-darwin, aarch64-unknown-linux-gnu) to be built, and IIUC what you need is support in the cargo llvm-cov report for the cargo-llvm-cov nextest --archive-file-specific target directory structure. (The code before the https://github.com/taiki-e/cargo-llvm-cov/pull/349 is probably easier to understand.)

The correct approach here is probably to add a new CLI flag for cargo llvm-cov report to enter this branch. https://github.com/taiki-e/cargo-llvm-cov/blob/bf4324422e9e62dd877372eb4a8015bf0c0c5839/src/main.rs#L735

taiki-e commented 6 months ago

The correct approach here is probably to add a new CLI flag for cargo llvm-cov report to enter this branch.

Opened #355 with this approach.