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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --fatal_warnings flag to treat warnings as errors #8131

Merged
merged 2 commits into from Mar 9, 2021

Conversation

perlun
Copy link
Contributor

@perlun perlun commented Dec 9, 2020

New attempt at #4336, building on top of the nice groundwork already provided by @benesch (appreciated!). Hoping we can get it to an approvable state this time. 馃槃

Because this builds on top of an existing MR, I decided to keep it as two separate commits - one for the rebased commit by @benesch and another one with my fixes. (There were some rebase conflicts that were amended into the original commit. One particular rebase conflict that I'm a bit hesitant about is https://github.com/protocolbuffers/protobuf/pull/4336/files#diff-cd3d05a33a7e35e0eeeff7b01f65d8744f20f08b1b179bb7ea3dc7e36e202d08R794; the constructor call looked differently here now so I removed that field setting altogether. Unsure if this is correct or not so please do advise.)

The newly added test runs fine locally with CLion but I'm not fully sure on how to run all the tests, so I'm hoping for the CI to tell me if the other tests pass or not with this change now. 馃檪

@google-cla
Copy link

google-cla bot commented Dec 9, 2020

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

鈩癸笍 Googlers: Go here for more info.

@benesch
Copy link
Contributor

benesch commented Dec 9, 2020

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Dec 9, 2020
@perlun
Copy link
Contributor Author

perlun commented Jan 22, 2021

@benesch Do you happen to know what the process is for getting someone to review this? It doesn't seem to be moving incredibly fast at the moment. 馃槄

@benesch
Copy link
Contributor

benesch commented Jan 22, 2021

The process is: find someone you know at Google, and ask them to internally ping someone on the protobuf team 馃槃. Only a little bit kidding.

@acozzette
Copy link
Member

It looks like the CommandLineInterfaceTest.InvalidErrorFormat test case is failing here:

ExpectErrorText("Unknown error format: invalid\n");

@perlun
Copy link
Contributor Author

perlun commented Feb 3, 2021

Thanks @acozzette, will give it a look. 馃憤

@perlun
Copy link
Contributor Author

perlun commented Mar 7, 2021

@acozzette There we go, I edited the test in question like this:

diff --git src/google/protobuf/compiler/command_line_interface_unittest.cc src/google/protobuf/compiler/command_line_interface_unittest.cc
index 15c9170a3..d1d14b81a 100644
--- src/google/protobuf/compiler/command_line_interface_unittest.cc
+++ src/google/protobuf/compiler/command_line_interface_unittest.cc
@@ -2330,7 +2330,7 @@ TEST_F(CommandLineInterfaceTest, InvalidErrorFormat) {
 
   Run("protocol_compiler --test_out=$tmpdir --proto_path=$tmpdir foo.proto");
 
-  ExpectErrorText("Unknown error format: invalid\n");
+  ExpectErrorText("foo.proto:2:1: Expected top-level statement (e.g. \"message\").\n");
 }
 
 TEST_F(CommandLineInterfaceTest, Warnings) {

This is admittedly quite na茂ve, I don't really understand why the semantics for this error changes because of the (seemingly unrelated) changes in this MR. If you understand it better, please let me know.

(I couldn't access the kokoro build logs for some reason, so I'm unsure if there's any more failures than this single one.)

@perlun perlun force-pushed the werror branch 3 times, most recently from eb36f3e to cfc668c Compare March 7, 2021 06:26
@perlun
Copy link
Contributor Author

perlun commented Mar 7, 2021

This is admittedly quite na茂ve, I don't really understand why the semantics for this error changes because of the (seemingly unrelated) changes in this MR. If you understand it better, please let me know.

I think I got it now. The test was changed in the original commit by @benesch (by mistake/intentionally? Hard to tell). I reverted that change back now and the original test assertion now succeeds, so we can minimize the impact of this PR (and hopefully get it merged soon). @acozzette - please trigger a new kokoro run so we can see if this is now (finally!) CI clean.

@perlun
Copy link
Contributor Author

perlun commented Mar 8, 2021

Thanks; there still seems to be some build failures (but the logs are still inaccessible to me, so slightly hard to see what they are). 馃槄

@acozzette
Copy link
Member

@perlun Sorry for the trouble, something's wrong with the permissions on our test logs. Here is the relevant error, though:

[ RUN      ] CommandLineInterfaceTest.InputsFromDescriptorSetInAndFileSystem_UnusedImportIsReported
google/protobuf/compiler/command_line_interface_unittest.cc:441: Failure
Expected equality of these values:
  0
  return_code_
    Which is: 1
[  FAILED  ] CommandLineInterfaceTest.InputsFromDescriptorSetInAndFileSystem_UnusedImportIsReported (16 ms)

benesch and others added 2 commits March 9, 2021 22:47
Add a --fatal_warnings flag that requests that protoc exit with a
failing status code if any warnings are generated during compilation.

Partially address protocolbuffers#3980.
@perlun
Copy link
Contributor Author

perlun commented Mar 9, 2021

@perlun Sorry for the trouble, something's wrong with the permissions on our test logs. Here is the relevant error, though:

No probs. 馃憤 Thanks for that. Interestingly enough, I don't think I'm able to reproduce this locally (not 100% sure since I started editing the code a bit too fast...). Anyhow, I made the new field default to false now more explicitly + swapped the order of the assertions in CommandLineInterfaceTest::ExpectWarningSubstring - if it fails again, we should hopefully get the invocation output in the log and not just the 1 != 0 part.

@acozzette please get the CI started one more time, maybe we're good to go this time. 馃 馃槃

@acozzette
Copy link
Member

The Python errors look to be unrelated, so I will go ahead and merge this. Thanks, @perlun!

@acozzette acozzette merged commit c7a6160 into protocolbuffers:master Mar 9, 2021
@perlun perlun deleted the werror branch March 10, 2021 08:46
@perlun
Copy link
Contributor Author

perlun commented Mar 10, 2021

Thanks for the merge @acozzette, greatly appreciated! 馃檹 馃憤

@benesch
Copy link
Contributor

benesch commented Mar 10, 2021

Woohoo! Thanks very much for the persistence @perlun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants