From 89a67aa9aaa007f1c7f9570b588ebb197e05bc60 Mon Sep 17 00:00:00 2001 From: Thomas Tendyck Date: Wed, 13 Sep 2023 18:49:20 +0200 Subject: [PATCH] test: wait for child processes to exit on test end --- test/framework/framework.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/framework/framework.go b/test/framework/framework.go index f8525a7a..19498b94 100644 --- a/test/framework/framework.go +++ b/test/framework/framework.go @@ -198,7 +198,14 @@ func (i IntegrationTest) StartCommand(friendlyName string, cmd *exec.Cmd) chan e waitErr := make(chan error) go func() { waitErr <- cmd.Wait() + close(waitErr) }() + + // On test end, wait until the process actually exited so that the next test can start cleanly. + i.t.Cleanup(func() { + _ = cmd.Cancel() + <-waitErr + }) return waitErr }