Repository navigation
testing: write output in binary mode on Windows - #715
Merged
Merged
Conversation
The C runtime's text mode turned every newline the test binary wrote into CRLF, so TestServerPanicFailsTest, which runs its own binary and matches the output against a pattern ending in a bare newline, failed on Windows. Go writes the bytes as they are.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What failed
Main's windows-mingw and windows-msvc jobs on 46a4a03 failed
httptest_testinTestServerPanicFailsTest. The test runs its own binary and matches the output against Go's pattern, which endsPANIC MESSAGE\n. The child's output (from job 122163786653's log) had a carriage return at the end of every line:--- FAIL: TestServerPanicFailsTest (0.00s)\r\n???:1: httptest: panic in server handler: PANIC MESSAGE\r\nSo the
\nright afterPANIC MESSAGEnever matched.The fix
The test runner writes through C stdio, and on Windows the C runtime's text mode turns each
\ninto\r\n. Go'sos.Stdoutwrites the bytes as they are.testing_m_runnow puts stdout and stderr in binary mode on Windows, with a "Not in Go" comment.The tests that already strip
\rfrom a child's output (log_test,fips140_cast_test,os_osexec_test) work either way. Example output is captured through a binary pipe already, andex_crlfstill strips CRLF from both sides as Go does.Testing
The change is only compiled on Windows, so the Linux servers can't test it. A syntax check and clang-format pass on the Mac. Main's Windows jobs after this merges are the real check.