-
Notifications
You must be signed in to change notification settings - Fork 442
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
Add test coverage support #1324
Conversation
rust/private/rustc.bzl
Outdated
@@ -791,6 +791,9 @@ def construct_arguments( | |||
rustc_flags.add("--extern") | |||
rustc_flags.add("proc_macro") | |||
|
|||
if ctx.configuration.coverage_enabled: | |||
rustc_flags.add("-Cinstrument-coverage") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was only added pretty recently, maybe even 1.60 even, not sure if we should try to gate something about this? Otherwise it was unstable / nightly only
So interestingly this is currently failing because of a mismatch in the version variable between clangrt, and rust's builtin libraries. What happens is that the info should be coming from |
This seems to be because the version of clangrt that ships with the latest Xcode version is still based on llvm 13, where rust is using llvm 14, and the expected profile version has changed significantly since there have been changes in the format. But I guess there is always potential for that mismatch so ideally we would solve that by making it prefer the rust library over the clang library. Although I have no idea how that might affect binaries that contained both rust and C++ |
Ok that can be worked around by passing |
Ok I've pushed an actual working version here, on my macOS machine you can test this in the examples workspace with:
|
1be0acc
to
e1d3d89
Compare
I think this is ready for some light review, some open questions that I'm not sure about:
|
@keith For CI it seems https://github.com/bazelbuild/continuous-integration/blob/master/buildkite/README.md#running-bazel-coverage is how you'd add jobs that test coverage. |
Thank you for working on this! In general looks good to me, but I'd like @krasimirgg to take a look too. |
This looks reasonable. I'm not very familiar with the coverage infrastructure, but wanted to ask a few questions anyways:
|
Good question, I think it would require them to not run
Interesting! I hadn't seen the
I haven't yet, and that's on my radar since C++ integration is our case as well. One immediate issue is the LLVM version mismatch issue I mentioned above, since I have been testing with clang with LLVM 13. I think we'll have to fix up issues as we hit them, but I imagine not all targets will work out of the box, which will lead to them just not producing any coverage info when you request it. The tests still pass because of this detail bazelbuild/bazel#15420 |
Friendly ping here, what's still outstanding on this PR? |
cdc3bd8
to
7b28d2f
Compare
I looked at adding CI, but if all we're doing is running |
Besides that I think the other outstanding concerns can probably be dealt with as needed in follow ups. |
I think there's value in at least running |
Sounds good, I pushed them to the existing jobs here, we'll see if it works out.
Not as far as I know, we have something internally for this, and envoy implements some post-processing script for it as well |
@hlopko @krasimirgg would you folks be able to take another look here? |
This PR looks good to me. I share @UebelAndre's view that it would be valuable setting up a build bot doing roughly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Looks good to me too, I'm happy to merge after the merge conflict is resolved. I also recommend adding a CI coverage (ba dum tsss) so we don't break it accidentally. That can be done in a followup PR. |
ea9a664
to
46f1eb7
Compare
I did add |
I think it's useful enough in just hitting those starlark code paths. I would say make an issue to add a step to verify coverage percentage. Ideally that would then become an issue in upstream Bazel. |
I leave it to @hlopko and @krasimirgg to determine when to merge. |
if we do merge please squash! |
@krasimirgg @hlopko any more to do here? |
This looks good and is ready to be merged. |
No description provided.