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

Various fixups to warnings flags #9344

Merged
merged 4 commits into from
May 13, 2022

Conversation

benesch
Copy link
Contributor

@benesch benesch commented Dec 25, 2021

Two commits in here that fix up some glitches in how libprotobuf/protoc handle warnings, described below.


Don't drop parser warnings on the floor

Fix #9343.


Convert "missing syntax" warning to an actual warning

For some reason this warning was emitted as a log message rather than a
structured warning. Convert it to use the AddWarning API so that it gets
emitted with a file and line number by protoc, and is visible via the
error collection interface during programmatic use.

benesch added a commit to MaterializeInc/rust-protobuf-native that referenced this pull request Dec 25, 2021
benesch added a commit to MaterializeInc/rust-protobuf-native that referenced this pull request Dec 25, 2021
benesch added a commit to MaterializeInc/rust-protobuf-native that referenced this pull request Dec 26, 2021
benesch added a commit to MaterializeInc/rust-protobuf-native that referenced this pull request Dec 26, 2021
@acozzette
Copy link
Member

@benesch Thank you for the pull request! This looks like a good change to me but I think there are some unit tests that need to be updated. Here is one test failure I see for example:

[ RUN      ] CommandLineInterfaceTest.PrintFreeFieldNumbers
src/google/protobuf/compiler/command_line_interface_unittest.cc:418: Failure
Expected equality of these values:
  ""
  error_text_
    Which is: "quz.proto:5:20: warning: Field name should be lowercase. Found: C. See: [https://developers.google.com/protocol-buffers/docs/style\nquz.proto:9:20](https://developers.google.com/protocol-buffers/docs/style/nquz.proto:9:20): warning: Field name should be lowercase. Found: E. See: [https://developers.google.com/protocol-buffers/docs/style\nquz.proto:11:22](https://developers.google.com/protocol-buffers/docs/style/nquz.proto:11:22): warning: Field name should be lowercase. Found: G. See: [https://developers.google.com/protocol-buffers/docs/style\n](https://developers.google.com/protocol-buffers/docs/style/n)"
With diff:
@@ -1,1 +1,3 @@
-""
+quz.proto:5:20: warning: Field name should be lowercase. Found: C. See: https://developers.google.com/protocol-buffers/docs/style
+quz.proto:9:20: warning: Field name should be lowercase. Found: E. See: https://developers.google.com/protocol-buffers/docs/style
+quz.proto:11:22: warning: Field name should be lowercase. Found: G. See: [https://developers.google.com/protocol-buffers/docs/style\n](https://developers.google.com/protocol-buffers/docs/style/n)

[  FAILED  ] CommandLineInterfaceTest.PrintFreeFieldNumbers (2 ms)

@acozzette
Copy link
Member

@benesch I am going to close this since there's been no activity in a few weeks, but if you would like to keep working on this then please let me know and I can reopen it.

@acozzette acozzette closed this Mar 4, 2022
@benesch
Copy link
Contributor Author

benesch commented Mar 4, 2022

Yes, I'll take a pass at fixing the test failures if you re-open. Hard to context switch back with the month-long latency is all, though now I'm guilty of that too!

@acozzette acozzette reopened this Mar 4, 2022
@benesch benesch force-pushed the warnings-fixups branch 2 times, most recently from e1dac2b to 07bd3b4 Compare April 17, 2022 19:15
For some reason this warning was emitted as a log message rather than a
structured warning. Convert it to use the AddWarning API so that it gets
emitted with a file and line number by protoc, and is visible via the
error collection interface during programmatic use.
@benesch
Copy link
Contributor Author

benesch commented Apr 17, 2022

I believe I've fixed the test failures. PTAL.

@acozzette
Copy link
Member

@benesch Thanks for taking another look! I still see one more test failure and I'm not sure what this is about:

[----------] 4 tests from LoggingTest
[ RUN      ] LoggingTest.DefaultLogging
unknown file: Failure
C++ exception with description "CHECK failed: (original_stderr_) == (-1): Already capturing." thrown in the test body.
[  FAILED  ] LoggingTest.DefaultLogging (0 ms)
[ RUN      ] LoggingTest.NullLogging
unknown file: Failure
C++ exception with description "CHECK failed: (original_stderr_) == (-1): Already capturing." thrown in the test body.
[  FAILED  ] LoggingTest.NullLogging (0 ms)

@benesch
Copy link
Contributor Author

benesch commented Apr 28, 2022

Oy, me neither! This one might be a bit beyond my capacity to debug. Any suggestions?

CaptureTestStderr() and GetCapturedTestStderr() have to be paired with each other.
@acozzette
Copy link
Member

I think I fixed the problem in parser_unittest.cc, but that seems to have uncovered some other tests that need to be updated.

@benesch
Copy link
Contributor Author

benesch commented Apr 29, 2022 via email

@acozzette
Copy link
Member

Sure, that would be great if you could take a look at the other failures.

A few tests now produce warnings that they didn't before, but were
expecting not to see any stderr output. Adjust the tests accordingly.
@benesch
Copy link
Contributor Author

benesch commented May 11, 2022

Ok, got them all passing locally. RFAL!

@acozzette acozzette merged commit 448d421 into protocolbuffers:main May 13, 2022
@acozzette
Copy link
Member

@benesch Thanks!

@benesch benesch deleted the warnings-fixups branch May 13, 2022 20:13
@benesch
Copy link
Contributor Author

benesch commented May 13, 2022

Thanks for all the help getting this through CI!

acozzette added a commit to acozzette/protobuf that referenced this pull request May 24, 2022
This reverts commit 448d421.

Unfortunately we have to revert this because we're finding that it
introduces too much new build log spam for existing proto files that are
out of compliance with the warnings. We might be able to roll it forward
again if we can figure out a way to do so without so many new log
messages.
acozzette added a commit that referenced this pull request May 24, 2022
This reverts commit 448d421.

Unfortunately we have to revert this because we're finding that it
introduces too much new build log spam for existing proto files that are
out of compliance with the warnings. We might be able to roll it forward
again if we can figure out a way to do so without so many new log
messages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warnings from parser are dropped on the floor
5 participants