@@ -100,11 +100,16 @@ func setup(ctx context.Context, t testing.TB) ([]ScriptEntry, *agentapisdk.Clien
100100		cwd , err  :=  os .Getwd ()
101101		require .NoError (t , err , "Failed to get current working directory" )
102102		binaryPath  =  filepath .Join (cwd , ".." , "out" , "agentapi" )
103+ 		_ , err  =  os .Stat (binaryPath )
104+ 		if  err  !=  nil  {
105+ 			t .Logf ("Building binary at %s" , binaryPath )
106+ 			buildCmd  :=  exec .CommandContext (ctx , "go" , "build" , "-o" , binaryPath , "." )
107+ 			buildCmd .Dir  =  filepath .Join (cwd , ".." )
108+ 			t .Logf ("run: %s" , buildCmd .String ())
109+ 			require .NoError (t , buildCmd .Run (), "Failed to build binary" )
110+ 		}
103111	}
104112
105- 	_ , err  =  os .Stat (binaryPath )
106- 	require .NoError (t , err , "Built binary not found at %s\n Run 'make build' to build the binary" , binaryPath )
107- 
108113	serverPort , err  :=  getFreePort ()
109114	require .NoError (t , err , "Failed to get free port for server" )
110115
@@ -188,6 +193,7 @@ func waitForServer(ctx context.Context, t testing.TB, url string, timeout time.D
188193				_  =  resp .Body .Close ()
189194				return  nil 
190195			}
196+ 			t .Logf ("Server not ready yet: %s" , err )
191197		}
192198	}
193199}
0 commit comments