fix: Improve shutdown procedure of ssh, portforward, wgtunnel cmds (#3354)

* fix: Improve shutdown procedure of ssh, portforward, wgtunnel cmds

We could turn it into a practice to wrap `cmd.Context()` so that we have
more fine-grained control of cancellation. Sometimes in tests we may be
running commands with a context that is never canceled.

Related to #3221

* fix: Set ssh session stderr to stderr
This commit is contained in:
Mathias Fredriksson
2022-08-02 17:44:59 +03:00
committed by GitHub
parent 5ae19f097e
commit 83c63d4a63
4 changed files with 75 additions and 53 deletions

View File

@ -229,7 +229,7 @@ func TestSSH(t *testing.T) {
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())
cmd.SetErr(io.Discard)
cmd.SetErr(pty.Output())
cmdDone := tGo(t, func() {
err := cmd.ExecuteContext(ctx)
assert.NoError(t, err)
@ -248,9 +248,6 @@ func TestSSH(t *testing.T) {
// And we're done.
pty.WriteLine("exit")
// Read output to prevent hang on macOS, see:
// https://github.com/coder/coder/issues/2122
pty.ExpectMatch("exit")
<-cmdDone
})
}