Skip to content
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

os, syscall: TestHostname and TestStdioAreInheritable get confused if hostname command emits warnings to stderr #52781

Closed
dmitshur opened this issue May 9, 2022 · 1 comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. OS-Windows Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@dmitshur
Copy link
Contributor

dmitshur commented May 9, 2022

This is really minor, but I've observed the following false positives:

$ go test -count=1 -run=TestStdioAreInheritable -v syscall
=== RUN   TestStdioAreInheritable
    syscall_windows_test.go:147: c program output is wrong: got "Cygwin WARNING:  Couldn't compute FAST_CWD pointer.  This typically occurs if you're using  an older Cygwin version on a newer Windows.  Please update to the latest  available Cygwin version from https://cygwin.com/.  If the problem persists,  please see https://cygwin.com/problems.htmlTABLET-ABCHello WorldCygwin WARNING:  Couldn't compute FAST_CWD pointer.  This typically occurs if you're using  an older Cygwin version on a newer Windows.  Please update to the latest  available Cygwin version from https://cygwin.com/.  If the problem persists,  please see https://cygwin.com/problems.htmlTABLET-ABC", want "TABLET-ABCHello WorldTABLET-ABC"
--- FAIL: TestStdioAreInheritable (6.81s)
FAIL
FAIL    syscall 6.959s
FAIL

$ go test -count=1 -run=TestHostname -v os
=== RUN   TestHostname
    os_test.go:1745: Hostname() = "TABLET-ABC" != system hostname of "Cygwin WARNING:\n  Couldn't compute FAST_CWD pointer.  This typically occurs if you're using\n  an older Cygwin version on a newer Windows.  Please update to the latest\n  available Cygwin version from https://cygwin.com/.  If the problem persists,\n  please see https://cygwin.com/problems.html\n\nTABLET-ABC"
--- FAIL: TestHostname (0.13s)
FAIL
FAIL    os      0.203s
FAIL

They occurred because in that environment the hostname command was emitting a warning to stderr, while still reporting the right hostname and exiting with code 0, but the test considered the stderr output to be a part of the hostname.

It happened due to an older Cygwin version on a newer Windows (after an upgrade of the latter), though I expect it can happen in other situations and on other OSes too. I think it's sufficient to rely on the command's exit code and ignore its stderr.

I've since resolved the problem in that environment so hostname doesn't print that performance warning to stderr, but figured I'll send a CL since the fix is trivial and should make the tests a tiny bit more robust (if I'm not mistaken).

@dmitshur dmitshur added Testing An issue that has been verified to require only test changes, not just a test failure. NeedsFix The path to resolution is known, but the work has not been done. labels May 9, 2022
@dmitshur dmitshur added this to the Backlog milestone May 9, 2022
@gopherbot
Copy link

Change https://go.dev/cl/405014 mentions this issue: os, syscall: don't consider stderr output as part of hostname

@dmitshur dmitshur modified the milestones: Backlog, Go1.19 May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. OS-Windows Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

No branches or pull requests

2 participants