googletest icon indicating copy to clipboard operation
googletest copied to clipboard

How to use EqualsProto to check protobuf?

Open yangminzhu opened this issue 6 years ago • 20 comments

The advanced doc says you can use gMock's EqualsProto to compare protos in your tests, but I find the EqualsProto is not defined inside gMock but in the nucleus repo that is used for parsing common genomics file.

I don't want to depend on this nucleus repo, so how can I use the EqualsProto in my project?

Thanks

yangminzhu avatar Aug 21 '18 01:08 yangminzhu

@yangminzhu Thank you for noticing. The docs are not completely synced / cleanup yet. It is possible that you are seeing reference to internal-only feature

gennadiycivil avatar Aug 31 '18 17:08 gennadiycivil

I don't know if this is supposed to be an internal-only feature, I found it from the public doc: https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#asserting-using-gmock-matchers and the source code is uploaded to https://github.com/google/nucleus/blob/master/nucleus/testing/protocol-buffer-matchers.h.

yangminzhu avatar Aug 31 '18 22:08 yangminzhu

What's the status of this issue? The advanced.md file references using ::testing::EqualsProto, but this matcher is not part of gmock.

devjgm avatar Jun 24 '19 20:06 devjgm

Hi,

Do we have any plans to move and OSS protocol-buffer-matchers.h to googletest?

neuromage avatar Jul 02 '19 18:07 neuromage

Any updates on this? Not having this be open source complicates open sourcing google projects.

smolkaj avatar May 06 '20 05:05 smolkaj

Is there a timeline on this (Suppose it's still on the roadmap)? I suppose it might not be as simple as copying over the two files in the necleus repo as I'd imagine the export need to be (somewhat) consistency with the current internal version?

dayfine avatar Jul 01 '20 07:07 dayfine

I too am interested in this

jheaff1 avatar Jul 01 '20 22:07 jheaff1

+1 this would be very useful to the Cloud C++ team. We have made do so far with our own hand-crafted matchers but having the full suite of proto-matchers would be nicer (and we can delete our own implementations).

mr-salty avatar Aug 04 '20 20:08 mr-salty

I could have used this too today. Please!

blais avatar Dec 24 '20 18:12 blais

protocol-buffer-matchers.h in Nucleus is heavily integrated with TensorFlow, it's not easy to include it without a rewrite.

buptsb avatar Jan 17 '21 02:01 buptsb

I forked them from Nucleus a while back and removed the unneeded dependencies:

https://github.com/inazarenko/protobuf-matchers

inazarenko avatar May 07 '21 23:05 inazarenko

@inazarenko Are you planning to merge it into the googletest repo? I also have a use case for it.

yangustc07 avatar Jul 14 '21 16:07 yangustc07

Are you planning to merge it into the googletest repo? I also have a use case for it.

No, I don't plan to merge it with googletest, but you can just pull my repo and use it. Or clone it if you want to be isolated from any changes I might make (although I don't have any current plans to change anything, it works fine as is for our purposes).

inazarenko avatar Jul 14 '21 22:07 inazarenko

Internal feature request https://buganizer.corp.google.com/issues/229726259 (Googlers only)

hickford avatar Apr 19 '22 13:04 hickford

If this is open sourced (and I think it should be), it will be part of the protobuf library, not GoogleTest. There is a lot of cleanup required first though.

derekmauro avatar Apr 19 '22 14:04 derekmauro

At the least, remove this from the documentation to avoid confusing people

alexolog avatar Jan 23 '23 21:01 alexolog

Friendly ping. The docs should remove references to EqualsProto() and any other matches that don't exist externally.

devjgm avatar Apr 18 '23 14:04 devjgm

Rather than removing the references, can we have the proto matchers as open source? I would love to use those in my project instead of hacking something together over MessageDifferencer.

wffurr avatar Apr 22 '24 15:04 wffurr

I'd also love for them to be a part of gTest/gMock.

@wffurr for now perhaps take a look at the repository linked here: https://github.com/google/googletest/issues/1761#issuecomment-834858070

inazarenko avatar Apr 22 '24 17:04 inazarenko