-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Generate coverage reports externally, no cargo binary #320
Comments
After you built the binaries, did you run them? If you have not run any, no profiles will be generated. If you run the binary, how exactly did you do it? (When using tools that do not propagate environment variables or parent directory structures, such as docker for example, environment variables must be propagated/mapped properly. See also #319 (comment)) |
My steps are as follows:
But there is no *.profraw file |
AFAIK, SIGKILL is currently not supported. See #235 for more. |
I found a problem, |
Is the *.profraw file generated when I run pytest (while the rust program is still working), and how do I trigger the *.profraw file |
set-env currently sets the following environment variables: export RUSTFLAGS='-C instrument-coverage --cfg=coverage --cfg=trybuild_no_target'
export LLVM_PROFILE_FILE='/path/to/target/name-%p-%10m.profraw'
export CARGO_LLVM_COV=1
export CARGO_LLVM_COV_SHOW_ENV=1
export CARGO_LLVM_COV_TARGET_DIR=/path/to/target The environment variables actually used in each step are different.
When using docker or other, absolute paths may need to be mapped to point to the same directory. (LLVM_PROFILE_FILE or/and CARGO_LLVM_COV_TARGET_DIR, depending on the situation)
IIRC, rust binary (or cdylib) will generate *.profraw file on exit. |
I tried using LLVM_PROFILE_FILE, but it didn't work. |
I have hit a similar issue, in this CI run. As can be seen there,
I thought this might be a bug in - run: echo "LLVM_PROFILE_FILE=$(pwd)/target/llvm-cov-target/nearcore-%p-%16m.profraw" >> "$GITHUB_ENV" However, this resulted in this other failing CI job, where the profraw was still not detected. I then tried to add back the The workflow I’m currently trying to get to work is the following: Do you have any idea what I’m doing wrong? AFAICT with the last iteration, I’m basically only trying to get the |
@Ekleog-NEAR One of the problems is that you are passing the output of --export-prefix to GITHUB_ENV; -export-prefix adds a prefix for the UNIX shell, which is not the format GITHUB_ENV expects. One of the ways is to save the output of --export-prefix to a file and |
Ooooh now I feel stupid for copy-pasting without checking the documentation ._. Thank you for the solution! I ended up with this code for setting the environment in a github action. Would you be interested in a PR that showcases the more "advanced" (multiple codecov labels, using with python tests that call into rust, etc.) use cases of cargo-llvm-cov in the readme? Also I’m curious, does llvm-cov actually need the whole target folder, or would it be possible to trim it somehow, to be able to share build artifacts across jobs without having to share the whole target folder? And if it’s possible (and significantly reduces the size of the target folder), would you be interested in a subcommand that cleans target to just leave the necessary stuff? Also, just to say, I had parsed |
A PR to add an example is welcome!
Only the binaries and profraw are actually needed to generate the report.
I have no strong opinion on the naming. That said, it may indeed be clearer to clarify that "export" is a noun, not a verb. |
One scenario I have is a program written in rust that exposes the http interface and does not generate Python-related dependency packages via pyo3.
Invoke http interface directly by executing request through pytest;
Is it possible for me to get a coverage report for this integration test?
Trying the following method so far does not generate the relevant *.profraw
In simple terms, for example, rust program is a back-end, it has a front-end page, can I get the coverage of the relevant operations through the front-end operations
The text was updated successfully, but these errors were encountered: