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 <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
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)
}
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))
}