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

Simplify and update code gen tests #14

Merged
merged 4 commits into from
Dec 3, 2024
Merged

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Nov 29, 2024

Motivation:

The protobuf code generator doesn't actually do a lot: it parses a protobuf file descriptor and turns that into a request for the code generator provided by the GRPCCodeGen module. This means that the tests should focus on the conversion rather than the generated code (although this is still useful to test at a high level).

As it stands all tests are done on the generated code rather than the conversion to a code generator request. The existing tests also hand roll a protobuf file descriptor which is tedious and error prone.

The upstream code generator also has changes which aren't yet reflected here.

Modifications:

  • Define some test proto files for which we generate serialized protobuf file descriptor sets.
  • Add a suite of code gen parser tests which check the request created from the file descriptor proto.
  • Add a single code generator test.
  • Downgrade an access level from public to package as public wasn't necessary.

Result:

Better tests

Motivation:

The protobuf code generator doesn't actually do a lot: it parses a
protobuf file descriptor and turns that into a request for the code
generator provided by the GRPCCodeGen module. This means that the tests
should focus on the conversion rather than the generated code (although
this is still useful to test at a high level).

As it stands all tests are done on the generated code rather than the
conversion to a code generator request. The existing tests also hand
roll a protobuf file descriptor which is tedious and error prone.

The upstream code generator also has changes which aren't yet reflected
here.

Modifications:

- Define some test proto files for which we generate serialized
  protobuf file descriptor sets.
- Add a suite of code gen parser tests which check the request created
  from the file descriptor proto.
- Add a single code generator test.
- Downgrade an access level from public to package as public wasn't
  necessary.

Result:

Better tests
@glbrntt glbrntt added the ⚠️ semver/major Breaks existing public API. label Nov 29, 2024
@glbrntt glbrntt added 🆕 semver/minor Adds new public API. and removed ⚠️ semver/major Breaks existing public API. labels Nov 29, 2024
@glbrntt glbrntt enabled auto-merge (squash) November 29, 2024 09:16
@@ -86,14 +92,16 @@ internal struct ProtobufCodeGenParser {
}

extension ProtobufCodeGenParser {
fileprivate var codeDependencies: [Dependency] {
fileprivate func codeDependencies(
Copy link
Collaborator

@rnro rnro Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: are the newlines in the signature intentional/needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I prefer a single line where possible. It was probably just an artefact of how I edited the existing code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth considering if there's value in a CI job to make sure these don't fall out of step with the generated code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll do this in a follow up given it's been auto-merged.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#15

Copy link
Collaborator

@rnro rnro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@glbrntt glbrntt merged commit 66dd0ce into grpc:main Dec 3, 2024
28 checks passed
@glbrntt glbrntt deleted the simplify-tests branch December 3, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants