-
Notifications
You must be signed in to change notification settings - Fork 406
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
Fix clippy rule not writing any content to the output file #1014
Conversation
CC @jfgoog |
When capturing output, the intention is that you should also specify --@rules_rust//:error_format=json, which does write to STDOUT. This is because the captured output is intended to be consumed by another step in the build process, so should be machine-readable. So, I think this change is not correct (and will actually break us). But clearly the documentation and tests should be better, for which I apologize. It would have been nice to make it so that capturing the output implies --error_format=json. The reason we did not do this in #937 was to keep logic related to clippy.bzl from creeping into rustc.bzl, which was already starting to happen until it was addressed in #850. |
Thanks for the review. I am actually using |
a9e0179
to
655b459
Compare
Yes, you do have to parse the JSON 1 line at a time. But I am surprised you are not seeing anything in STDOUT. What is your platform and rust version? |
I'm on Linux and my current toolchain is |
We are using rustc nightly 2021-11-02 on Linux, and rules_rust 0c53d0e from 2021-10-27, and I have re-confirmed that I am seeing the clippy output captured correctly. |
I'm puzzled. I've just pushed a commit that picks the same nightly version you are using when setting up the repository and still only seeing the content being written out when using |
I patched in your change, and reproduced what you are seeing with This makes me wonder if there's something weird about blaze vs. bazel, or if we are doing something odd when building our Rust toolchain. I'm going to keep investigating. |
Thanks for your time, I appreciate it. |
OK, I think I figured out what's going on. For "reasons", we run clippy via a wrapper script that does "exec 2>&1" to redirect stderr to stdout. So I think your change is correct. Would you mind holding off on submitting while I chat with some other folks about how to handle this? |
Absolutely. I'm actually migrating a largish codebase from our own custom rust rules + cargo-clippy to |
Apparently nobody here has any idea why we redirect sterr to stdout. Going to apply your change locally and see if anything breaks. |
I patched in your change, and things seem to work fine without the redirect. So I think we should review your change and get it submitted. We will just have to remember to remove the |
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.
Thanks for catching this, and for improving the tests.
And log output file path when failing.
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.
Thank you!
I noticed that when running a
rust_clippy
target, no content was actually written to the output file. This is because Clippy writes its output tostderr
but the rule was only setting--stdout-file
.I’ve changed it to write
stderr
to the output file instead.Also tweaked the test to check that content was actually written to the file. It fails before the patch and passes after.