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

Protoc comparison test #32

Merged
merged 4 commits into from Dec 30, 2019
Merged

Protoc comparison test #32

merged 4 commits into from Dec 30, 2019

Conversation

cb372
Copy link
Member

@cb372 cb372 commented Dec 30, 2019

Add a property-based test to check that the bytes generated by pbdirect for a complex message are identical to the output of the protoc command-line tool.

The test works as follows.

For a given randomly-generated message:

  1. Encode the message to protobuf bytes using pbdirect
  2. Encode the message to protobuf text format using a simple hand-written encoder. This is the format that protoc wants as its input
  3. Use protoc to encode the message to protobuf bytes, passing it the text-format encoded message and a .proto file as input
  4. Assert that the output from pbdirect and protoc are identical

We generate a random message, encode it in protobuf text format, use
both pbdirect and protoc to encode it as protobuf binary, and compare
the resulting bytes.
Copy link

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

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

👍

* But then we'd be basically reinventing the whole
* library but for text instead of binary, and then using
* that to test the behaviour of the library. Feels a bit
* weird.

Choose a reason for hiding this comment

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

😁

Copy link

@fedefernandez fedefernandez left a comment

Choose a reason for hiding this comment

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

💯

@cb372 cb372 merged commit c2c5daf into master Dec 30, 2019
@cb372 cb372 deleted the protoc-comparison-tests branch December 30, 2019 18:34
@cb372
Copy link
Member Author

cb372 commented Dec 30, 2019

Looks like this test is flaky on Travis, but works fine for me locally. So the build is broken on master now 😞

Looking at this log, it looks like protoc sometimes outputs nothing, which means the process probably failed to run. I'll investigate.

@cb372 cb372 mentioned this pull request Dec 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants