Skip to content

Commit 8b88538

Browse files
committed
wait for output goroutine to finish
1 parent 24ff884 commit 8b88538

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

internal/provider/git_test.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,24 @@ func startSSHServer(ctx context.Context, t testing.TB) string {
125125
t.Logf("command failed: %s", err)
126126
return
127127
}
128-
t.Cleanup(func() {
129-
_ = in.Close()
130-
_ = out.Close()
131-
_ = cmd.Process.Kill()
132-
})
133128

134129
go func() {
135130
_, _ = io.Copy(in, s)
136131
_ = in.Close()
137132
}()
133+
outDone := make(chan struct{})
138134
go func() {
135+
defer close(outDone)
139136
_, _ = io.Copy(s, out)
140137
_ = out.Close()
141138
_ = s.CloseWrite()
142139
}()
140+
t.Cleanup(func() {
141+
_ = in.Close()
142+
_ = out.Close()
143+
<-outDone
144+
_ = cmd.Process.Kill()
145+
})
143146
err = cmd.Wait()
144147
if err != nil {
145148
t.Logf("command failed: %s", err)

0 commit comments

Comments
 (0)