-
Notifications
You must be signed in to change notification settings - Fork 210
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
Non-determinism: leading space characters in diff occasionally turn into non-breaking space #366
Comments
Hi @mejedi, sorry to hear about the issue, but this is working as intended. The documentation on Diff says:
The output of Diff has in the past and will continue to change because it is intended to evolve to be more and more humanly readable. Codifying it's output in something like an example test would mean that the test is brittle and breaks whenever Diff's output changes again. The instability of the output was done to deliberately make it harder to accidentally assume that the output was stable. |
Hi @dsnet, thank you for the prompt reply. At the moment, I use What is the best way to showcase Re intentional non-determinism: I agree with the idea. The current implementation however is rather hostile. Go test results are cached, AND the probabilities of different outcomes are very skewed, AND the difference in the output is hard to tell with a naked eye. |
Unfortunately there is no answer at the moment, but the ability to evolve the output is currently deemed a greater benefit than stability. I've long thought about forking the current reporter implementation and codifying it as "stable". This way we can continue to evolve the default output, and also provide a stable output for use cases that need it. Output in example docs is a legitimate reason to want a stable format. |
I noticed that
cmp.Diff
alternates between regular and non-breaking space in +- column. One is way more likely to get regular space.This behavior creates issues when output is compared verbatim, e.g. in testable examples:
It fails occasionally with the following output. Using
go test -bench=.
somehow makes it more likely to manifest.The text was updated successfully, but these errors were encountered: