Skip to content

testing: write output in binary mode on Windows - #715

Merged
tamnd merged 1 commit into
mainfrom
win-test-lf
Oct 27, 2026
Merged

tamnd merged 1 commit into
mainfrom
win-test-lf

Conversation

@tamnd

@tamnd tamnd commented Oct 27, 2026

Copy link
Copy Markdown
Owner

What failed

Main's windows-mingw and windows-msvc jobs on 46a4a03 failed httptest_test in TestServerPanicFailsTest. The test runs its own binary and matches the output against Go's pattern, which ends PANIC MESSAGE\n. The child's output (from job 122163786653's log) had a carriage return at the end of every line:

Line in the log Ends with
--- FAIL: TestServerPanicFailsTest (0.00s) \r\n
???:1: httptest: panic in server handler: PANIC MESSAGE \r\n

So the \n right after PANIC MESSAGE never matched.

The fix

The test runner writes through C stdio, and on Windows the C runtime's text mode turns each \n into \r\n. Go's os.Stdout writes the bytes as they are. testing_m_run now puts stdout and stderr in binary mode on Windows, with a "Not in Go" comment.

The tests that already strip \r from a child's output (log_test, fips140_cast_test, os_osexec_test) work either way. Example output is captured through a binary pipe already, and ex_crlf still 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.

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.
@tamnd tamnd added the area: runtime Scheduler, goroutines, channels, select, defer, panic, netpoller label Oct 27, 2026
@tamnd
tamnd merged commit 4675638 into main Oct 27, 2026
0 of 44 checks passed
@tamnd
tamnd deleted the win-test-lf branch October 27, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Scheduler, goroutines, channels, select, defer, panic, netpoller

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant