testing: Testable examples collapse Output
newlines, making them impossible to pass
#59191
Labels
Milestone
Output
newlines, making them impossible to pass
#59191
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?❌ Not relevant, this happens in multiple environments including Go Playground with Go 1.19 and Go 1.20
What did you do?
Output
annotation is modified by thetesting
parserMinimal example
Viewable here: https://go.dev/play/p/LFktKVr75lz
✅ The
ExampleFoo
function returns data containing successive newlines:✅ The
ExampleFoo
contains an embeddedOutput:
annotation with the same expected output:✅ The
Output
andstdout
are compared, with leading and trailing whitespace removed❌ Multiple newlines are collapsed into single newlines, making the test fail - only solution is to modify the function under test (which is not an option)
What did you expect to see?
Output:
should be parsed as-is, not modified (beyond trimming leading and trailing whitespace)What did you see instead?
The multiple empty lines are collapsed into a single empty line
Additional context
Did a little hunting to see if I could find a root cause, no success yet
Currently suspect it's either hidden somewhere within the
testing
package, or is an unintended side effect of how chains of single line comments are parsed byast
The text was updated successfully, but these errors were encountered: