-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
Formatting Cyclic Types produces infinite output #830
Comments
hey thanks for bringing this up and proposing a solution (and including a PR!) i'm open to the approach you've taken though we'll need to add some documentation to make it discoverable. some thoughts though:
Thoughts? Would you be up for giving the latter a try in the PR? |
That's a situation I'm constantly battling with in my lxkns and ghostwire packages, with their cyclic data structures. As onsi points out, an annotation probably doesn't help, because the annotation's placement would need to be test-specific, depending on where in the probably cyclic graph your test "starts". The cycle detection looks much more promising. |
The cycle detection would be a better long-term solution, which I did consider at first, and I've be happy to try that as well, however, this was more of a quick-and-dirty solution to get me unblocked in my particular use case that didn't require re-doing any of the internals of the package. That said, I think the tag approach is still useful in the short term (albleit with a better name, maybe |
the more i think about it the less confident i am about an Someday™ building out Gomega's own equality library would be a good investment as it would enable this sort of usecase (so many times i've wanted to just suppress checking for equality on "uninteresting" fields like timestamps or coordinates). But that's too much scope for this, imo. So... I think an approach that does the cycle detection, scoped to each invocation of |
Yeah, I can take a look at that, but it probably won't be right away. |
When using gomega (and, by extension, ginkgo) with cyclic types, the output from formatting the objects from e.g.
Expect(foo).To(Equal(bar))
is infinite, and if the cyclic pointer field is early in the struct, the actual differing fields may never actually be printed. This renders this output nearly useless.I would like to propose and implement adding a new struct tag
gomega:"omit"
which replaces the formatting output of that field with a message indicating it was omitted, plus the address if it was a pointer. This would allow cyclic types to be formatted finitely.The text was updated successfully, but these errors were encountered: