e5f8b20b18cf55723f07c4f6f525107ee453f152

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix(tests): testscript race condition

Diff

 1diff --git a/testscript/script_test.go b/testscript/script_test.go
 2index 2c9c0bc32f54a482635b9cdf940c1f8d60b5b626..7c345dd71d4b7f9dfddff1443af84c98c4cfd4f5 100644
 3--- a/testscript/script_test.go
 4+++ b/testscript/script_test.go
 5@@ -134,13 +134,10 @@ func TestScript(t *testing.T) {
 6 			be := backend.New(ctx, cfg, dbx)
 7 			ctx = backend.WithContext(ctx, be)
 8 
 9-			// prevent race condition in lipgloss...
10-			// this will probably be autofixed when we start using the colors
11-			// from the ssh session instead of the server.
12-			// XXX: take another look at this soon
13 			lock.Lock()
14 			srv, err := server.NewServer(ctx)
15 			if err != nil {
16+				lock.Unlock()
17 				return err
18 			}
19 			lock.Unlock()
20@@ -155,6 +152,8 @@ func TestScript(t *testing.T) {
21 				defer dbx.Close() // nolint: errcheck
22 				ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
23 				defer cancel()
24+				lock.Lock()
25+				defer lock.Unlock()
26 				if err := srv.Shutdown(ctx); err != nil {
27 					e.T().Fatal(err)
28 				}