4915ba93e932b377ce9022c914a3a3a32ee3c337

Author
Kieran Klukas <kieran@dunkirk.sh>
Committer
Kieran Klukas <kieran@dunkirk.sh>
Date

Message

chore: fix test flake

Diff

 1diff --git a/testscript/script_test.go b/testscript/script_test.go
 2index 2687dba7e894cc5f59fa67714acdc77633e16a12..f8b9a8dab3ccf3caab7f2a81b3dbc186bc5060af 100644
 3--- a/testscript/script_test.go
 4+++ b/testscript/script_test.go
 5@@ -539,6 +539,7 @@ func cmdEnsureServerRunning(ts *testscript.TestScript, neg bool, args []string)
 6 
 7 	// verify that the server is up
 8 	addr := net.JoinHostPort("localhost", port)
 9+	deadline := time.Now().Add(30 * time.Second)
10 	for {
11 		conn, _ := net.DialTimeout( //nolint:noctx
12 			"tcp",
13@@ -550,6 +551,10 @@ func cmdEnsureServerRunning(ts *testscript.TestScript, neg bool, args []string)
14 			conn.Close()
15 			break
16 		}
17+		if time.Now().After(deadline) {
18+			ts.Fatalf("server on port %s did not start within 30 seconds", port)
19+		}
20+		time.Sleep(10 * time.Millisecond)
21 	}
22 }
23