From e5f8b20b18cf55723f07c4f6f525107ee453f152 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 2 Aug 2023 14:06:17 -0400 Subject: [PATCH] fix(tests): testscript race condition --- testscript/script_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/testscript/script_test.go b/testscript/script_test.go index 2c9c0bc32f54a482635b9cdf940c1f8d60b5b626..7c345dd71d4b7f9dfddff1443af84c98c4cfd4f5 100644 --- a/testscript/script_test.go +++ b/testscript/script_test.go @@ -134,13 +134,10 @@ func TestScript(t *testing.T) { be := backend.New(ctx, cfg, dbx) ctx = backend.WithContext(ctx, be) - // prevent race condition in lipgloss... - // this will probably be autofixed when we start using the colors - // from the ssh session instead of the server. - // XXX: take another look at this soon lock.Lock() srv, err := server.NewServer(ctx) if err != nil { + lock.Unlock() return err } lock.Unlock() @@ -155,6 +152,8 @@ func TestScript(t *testing.T) { defer dbx.Close() // nolint: errcheck ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() + lock.Lock() + defer lock.Unlock() if err := srv.Shutdown(ctx); err != nil { e.T().Fatal(err) }