ssh/test: deflake session test. The session test previously had a one second timeout for the output of stty and this was leading to flakiness. This change removes the timeout since go test has a generic timeout mechanism. Additionally, the test was looking for "-echo" in the output to test the value of the echo flag. However, there are also typically "echoe", "echok" and "echonl" flags, and "-echo" could be a prefix of any of time. Thus we now also match a trailing space. R=golang-dev, rsc, extraterrestrial.neighbour CC=golang-dev https://golang.org/cl/7579043
diff --git a/ssh/test/session_test.go b/ssh/test/session_test.go index 532bb7b..4393ee9 100644 --- a/ssh/test/session_test.go +++ b/ssh/test/session_test.go
@@ -14,7 +14,6 @@ "io" "strings" "testing" - "time" ) func TestRunCommandSuccess(t *testing.T) { @@ -154,22 +153,12 @@ stdin.Write([]byte("stty -a && exit\n")) - rc := make(chan string) - go func() { - var buf bytes.Buffer - if _, err := io.Copy(&buf, stdout); err != nil { - t.Fatalf("reading failed: %s", err) - } - rc <- buf.String() - }() - - result := "" - select { - case result = <-rc: - case <-time.After(1 * time.Second): + var buf bytes.Buffer + if _, err := io.Copy(&buf, stdout); err != nil { + t.Fatalf("reading failed: %s", err) } - if !strings.Contains(result, "-echo") { - t.Fatalf("terminal mode failure: expected '%s'", "-echo") + if sttyOutput := buf.String(); !strings.Contains(sttyOutput, "-echo ") { + t.Fatalf("terminal mode failure: expected -echo in stty output, got %s", sttyOutput) } }