diff options
| author | Adam Langley <agl@golang.org> | 2013-03-08 10:09:40 -0500 |
|---|---|---|
| committer | Adam Langley <agl@golang.org> | 2013-03-08 10:09:40 -0500 |
| commit | dc703e91d7bf2ed50e4e847371f53a4c0a83693c (patch) | |
| tree | 7c48e90b2e8c78023b6eefbf08145f06624e328e /ssh/test/session_test.go | |
| parent | eccdd1285ab9ae1cb35bf3b90d777d304263f478 (diff) | |
| download | go-x-crypto-dc703e91d7bf2ed50e4e847371f53a4c0a83693c.tar.xz | |
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
Diffstat (limited to 'ssh/test/session_test.go')
| -rw-r--r-- | ssh/test/session_test.go | 21 |
1 files changed, 5 insertions, 16 deletions
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 @@ import ( "io" "strings" "testing" - "time" ) func TestRunCommandSuccess(t *testing.T) { @@ -154,22 +153,12 @@ func TestValidTerminalMode(t *testing.T) { 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) } } |
