Skip to content

Commit a2a5fcf

Browse files
authored
fix: prevent test flake by waiting on copy (#27)
1 parent a4e82b3 commit a2a5fcf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/provider/git_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,19 @@ func startSSHServer(ctx context.Context, t testing.TB) string {
135135
_, _ = io.Copy(in, s)
136136
_ = in.Close()
137137
}()
138+
outCopyDone := make(chan struct{})
138139
go func() {
139140
_, _ = io.Copy(s, out)
140141
_ = out.Close()
141-
_ = s.CloseWrite()
142+
close(outCopyDone)
142143
}()
143144
err = cmd.Wait()
144145
if err != nil {
145146
t.Logf("command failed: %s", err)
146147
}
148+
<-outCopyDone
147149

148-
t.Logf("session ended: %s", s.RawCommand())
150+
t.Logf("session ended (cmd=%q, code=%d)", s.RawCommand(), cmd.ProcessState.ExitCode())
149151

150152
err = s.Exit(cmd.ProcessState.ExitCode())
151153
if err != nil {

0 commit comments

Comments
 (0)