-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
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
@@ -86,14 +92,16 @@ internal struct ProtobufCodeGenParser { | |||
} | |||
|
|||
extension ProtobufCodeGenParser { | |||
fileprivate var codeDependencies: [Dependency] { | |||
fileprivate func codeDependencies( |
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.
nit: are the newlines in the signature intentional/needed?
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.
No, I prefer a single line where possible. It was probably just an artefact of how I edited the existing code.
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.
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.
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.
Good point, I'll do this in a follow up given it's been auto-merged.
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.
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.
Looks good!
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:
Result:
Better tests