Skip to content
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

Separate build from execution & report generation #319

Closed
MiniaczQ opened this issue Oct 6, 2023 · 9 comments
Closed

Separate build from execution & report generation #319

MiniaczQ opened this issue Oct 6, 2023 · 9 comments
Labels
C-question Category: A question

Comments

@MiniaczQ
Copy link

MiniaczQ commented Oct 6, 2023

This is a mirror issue to another coverage tool xd009642/tarpaulin#1352

Is it possible to build binaries, then move them to special environments (like docker images) and run coverage and reports there separately?

@taiki-e
Copy link
Owner

taiki-e commented Oct 6, 2023

I don't know your exact use case, but show-env + report might work: https://github.com/taiki-e/cargo-llvm-cov?tab=readme-ov-file#get-coverage-of-external-tests

@MiniaczQ
Copy link
Author

MiniaczQ commented Oct 6, 2023

The exact use case would be building all of the test binaries together, with cache available, then separating them to:

  • unit tests, no special environment
  • integration tests, docker image, docker compose with specific services available
    then combining all results through another tool

@taiki-e
Copy link
Owner

taiki-e commented Oct 6, 2023

If you want to run the built binaries in containors you need to bind the target directory and map LLVM_PROFILE_FILE env var properly, but show-env + report should work.

@MiniaczQ
Copy link
Author

MiniaczQ commented Oct 6, 2023

Alright, I'll try it out and see how it goes.
Thank you :)

@taiki-e
Copy link
Owner

taiki-e commented Oct 6, 2023

If you want to run the built binaries in containors you need to bind the target directory and map LLVM_PROFILE_FILE env var properly

I checked locally and something like the following worked:

source <(cargo llvm-cov show-env --export-prefix)

cargo build

docker run --rm -d -it \
  -v "$(pwd)":/workdir \
  --env LLVM_PROFILE_FILE="${LLVM_PROFILE_FILE/"$(pwd)"//workdir}" \
  ubuntu sh -c '/workdir/target/debug/<bin-name> --version'

cargo llvm-cov report --html

@MiniaczQ
Copy link
Author

MiniaczQ commented Oct 9, 2023

The assumption is that I provide all the test binaries paths, which requires build result parsing the build results.
I believe this is also different between cargo test and nextest

@taiki-e
Copy link
Owner

taiki-e commented Oct 9, 2023

For cargo test you can get test binary paths while building the test binaries by calling cargo test --no-run --message-format=json and parsing the output JSON.

@MiniaczQ
Copy link
Author

MiniaczQ commented Oct 13, 2023

I did a setup with nextest, since it provides a better way to package test binaries, here's the attempt, it doesn't generate profraws and I'm not sure why
nextest-rs/nextest#1036

@taiki-e
Copy link
Owner

taiki-e commented Oct 15, 2023

Closing -- this seems to be solved nextest-rs/nextest#1036 (comment)

@taiki-e taiki-e closed this as completed Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-question Category: A question
Projects
None yet
Development

No branches or pull requests

2 participants