github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/integration/tilt_args_test.go (about)

     1  //go:build integration
     2  // +build integration
     3  
     4  package integration
     5  
     6  import (
     7  	"fmt"
     8  	"testing"
     9  	"time"
    10  
    11  	"github.com/stretchr/testify/require"
    12  )
    13  
    14  func TestTiltArgs(t *testing.T) {
    15  	f := newFixture(t, "tilt_args")
    16  
    17  	f.TiltUp("foo")
    18  
    19  	f.logs.AssertEventuallyContains(t, "foo run", 5*time.Second)
    20  	f.logs.Reset()
    21  
    22  	err := f.tilt.Args(f.ctx, []string{"bar"}, f.LogWriter())
    23  	if err != nil {
    24  		// Currently, Tilt starts printing logs before the webserver has bound to a port.
    25  		// If this happens, just sleep for a second and try again.
    26  		duration := 2 * time.Second
    27  		fmt.Printf("Error setting args. Sleeping (%s): %v\n", duration, err)
    28  
    29  		time.Sleep(duration)
    30  		err = f.tilt.Args(f.ctx, []string{"bar"}, f.LogWriter())
    31  		require.NoError(t, err)
    32  	}
    33  
    34  	f.logs.AssertEventuallyContains(t, "bar run", 5*time.Second)
    35  
    36  	require.NotContains(t, f.logs.String(), "foo run")
    37  }