From ac3596a7d7bf5f5e86b665b1ac06afc5aac9e430 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Mon, 10 Jun 2024 23:07:01 +0200 Subject: [PATCH] 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. --- ctl_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ctl_test.go b/ctl_test.go index 7713c7e..53dee1b 100644 --- a/ctl_test.go +++ b/ctl_test.go @@ -56,9 +56,14 @@ func TestCtl(t *testing.T) { cconn, sconn := net.Pipe() clientctl := ctl{conn: cconn, log: pkglog} serverctl := ctl{conn: sconn, log: pkglog} - go servectlcmd(ctxbg, &serverctl, func() {}) + done := make(chan struct{}) + go func() { + servectlcmd(ctxbg, &serverctl, func() {}) + close(done) + }() fn(&clientctl) cconn.Close() + <-done sconn.Close() }