Skip to content

Commit ac3596a

Browse files
committed
try fixing race in tests of ctl socket
there were a few test failures on the github runners. i can't reproduce it locally. but i can see how they are happening: a gorouting running servectlcmd could still be doing cleanup (removing files) while a next ctl command was being run. with this change, we wait for servectlcmd to be done before starting on a next test.
1 parent 8254e9c commit ac3596a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ctl_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ func TestCtl(t *testing.T) {
5656
cconn, sconn := net.Pipe()
5757
clientctl := ctl{conn: cconn, log: pkglog}
5858
serverctl := ctl{conn: sconn, log: pkglog}
59-
go servectlcmd(ctxbg, &serverctl, func() {})
59+
done := make(chan struct{})
60+
go func() {
61+
servectlcmd(ctxbg, &serverctl, func() {})
62+
close(done)
63+
}()
6064
fn(&clientctl)
6165
cconn.Close()
66+
<-done
6267
sconn.Close()
6368
}
6469

0 commit comments

Comments
 (0)