From: Dmitri Shuralyov Date: Mon, 9 May 2022 03:04:28 +0000 (-0400) Subject: os, syscall: don't consider stderr output as part of hostname X-Git-Tag: go1.19beta1~343 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0d410d676dde6cf5f2fc6f78ed7f2c39181d6720;p=gostls13.git os, syscall: don't consider stderr output as part of hostname A successful invocation of the hostname command prints the hostname to stdout and exits with code 0. No part of the hostname is printed to stderr, so don't consider it. This avoids false positive failures in environments where hostname prints some extraneous information (such as performance warnings) to stderr, and makes the test a bit more robust. Fixes #52781. Change-Id: I46aa6fbf95b6616bacf9c2b5e412b0851b230744 Reviewed-on: https://go-review.googlesource.com/c/go/+/405014 Auto-Submit: Dmitri Shuralyov Run-TryBot: Dmitri Shuralyov Reviewed-by: Bryan Mills Reviewed-by: Dmitri Shuralyov Reviewed-by: Jason Donenfeld TryBot-Result: Gopher Robot --- diff --git a/src/os/os_test.go b/src/os/os_test.go index df00f165da..8e2b4f3aaa 100644 --- a/src/os/os_test.go +++ b/src/os/os_test.go @@ -1736,7 +1736,7 @@ func runBinHostname(t *testing.T) string { func testWindowsHostname(t *testing.T, hostname string) { cmd := osexec.Command("hostname") - out, err := cmd.CombinedOutput() + out, err := cmd.Output() if err != nil { t.Fatalf("Failed to execute hostname command: %v %s", err, out) } diff --git a/src/syscall/syscall_windows_test.go b/src/syscall/syscall_windows_test.go index 194c87805c..87f6580bdc 100644 --- a/src/syscall/syscall_windows_test.go +++ b/src/syscall/syscall_windows_test.go @@ -130,7 +130,7 @@ int main(int argc, char *argv[]) if err != nil { t.Fatalf("failed to build c executable: %s\n%s", err, out) } - out, err = exec.Command(exe).CombinedOutput() + out, err = exec.Command(exe).Output() if err != nil { t.Fatalf("c program execution failed: %v: %v", err, string(out)) }