Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions internal/engine/buildcontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
)

func TestBuildControllerLocalResource(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

dep := f.JoinPath("stuff.json")
Expand Down Expand Up @@ -55,6 +56,7 @@ func TestBuildControllerLocalResource(t *testing.T) {
}

func TestBuildControllerManualTriggerBuildReasonInit(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
triggerMode model.TriggerMode
Expand All @@ -63,6 +65,7 @@ func TestBuildControllerManualTriggerBuildReasonInit(t *testing.T) {
{"manual with auto init", model.TriggerModeManualWithAutoInit},
} {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
f := newTestFixture(t)
mName := model.ManifestName("foobar")
manifest := f.newManifest(mName.String()).WithTriggerMode(tc.triggerMode)
Expand All @@ -84,6 +87,7 @@ func TestBuildControllerManualTriggerBuildReasonInit(t *testing.T) {
}

func TestTriggerModes(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
triggerMode model.TriggerMode
Expand All @@ -96,6 +100,7 @@ func TestTriggerModes(t *testing.T) {
{name: "fully manual", triggerMode: model.TriggerModeManual, expectInitialBuild: false, expectBuildWhenFilesChange: false},
} {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

manifest := f.simpleManifestWithTriggerMode("foobar", tc.triggerMode)
Expand Down Expand Up @@ -129,6 +134,7 @@ func TestTriggerModes(t *testing.T) {
}

func TestBuildControllerImageBuildTrigger(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
triggerMode model.TriggerMode
Expand All @@ -143,6 +149,7 @@ func TestBuildControllerImageBuildTrigger(t *testing.T) {
{name: "auto with manual init without change", triggerMode: model.TriggerModeAutoWithManualInit, filesChanged: false, expectedImageBuild: true},
} {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
f := newTestFixture(t)
mName := model.ManifestName("foobar")

Expand Down Expand Up @@ -187,6 +194,7 @@ func TestBuildControllerImageBuildTrigger(t *testing.T) {
}

func TestBuildQueueOrdering(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

m1 := f.newManifestWithRef("manifest1", container.MustParseNamed("manifest1")).
Expand Down Expand Up @@ -241,6 +249,7 @@ func TestBuildQueueOrdering(t *testing.T) {
}

func TestBuildQueueAndAutobuildOrdering(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

// changes to this dir. will register with our manual manifests
Expand Down Expand Up @@ -303,6 +312,7 @@ func TestBuildQueueAndAutobuildOrdering(t *testing.T) {

// any manifests without image targets should be deployed before any manifests WITH image targets
func TestBuildControllerNoBuildManifestsFirst(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

manifests := make([]model.Manifest, 10)
Expand Down Expand Up @@ -341,6 +351,7 @@ func TestBuildControllerNoBuildManifestsFirst(t *testing.T) {
}

func TestBuildControllerUnresourcedYAMLFirst(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

manifests := []model.Manifest{
Expand Down Expand Up @@ -371,6 +382,7 @@ func TestBuildControllerUnresourcedYAMLFirst(t *testing.T) {
}

func TestBuildControllerRespectDockerComposeOrder(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

sancho := NewSanchoLiveUpdateDCManifest(f)
Expand Down Expand Up @@ -399,6 +411,7 @@ func TestBuildControllerRespectDockerComposeOrder(t *testing.T) {
}

func TestBuildControllerLocalResourcesBeforeClusterResources(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

manifests := []model.Manifest{
Expand Down Expand Up @@ -440,6 +453,7 @@ func TestBuildControllerLocalResourcesBeforeClusterResources(t *testing.T) {
}

func TestBuildControllerResourceDeps(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

depGraph := map[string][]string{
Expand Down Expand Up @@ -497,6 +511,7 @@ func TestBuildControllerResourceDeps(t *testing.T) {
// normally, local builds go before k8s builds
// if the local build depends on the k8s build, the k8s build should go first
func TestBuildControllerResourceDepTrumpsLocalResourcePriority(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

k8sManifest := f.newManifest("foo")
Expand Down Expand Up @@ -525,6 +540,7 @@ func TestBuildControllerResourceDepTrumpsLocalResourcePriority(t *testing.T) {

// bar depends on foo, we build foo three times before marking it ready, and make sure bar waits
func TestBuildControllerResourceDepTrumpsInitialBuild(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("flaky on windows")
}
Expand Down Expand Up @@ -560,6 +576,7 @@ func TestBuildControllerResourceDepTrumpsInitialBuild(t *testing.T) {

// bar depends on foo. make sure bar waits on foo even as foo fails
func TestBuildControllerResourceDepTrumpsPendingBuild(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("flaky on windows")
}
Expand Down Expand Up @@ -593,6 +610,7 @@ func TestBuildControllerResourceDepTrumpsPendingBuild(t *testing.T) {
}

func TestBuildControllerWontBuildManifestIfNoSlotsAvailable(t *testing.T) {
t.Parallel()
f := newTestFixture(t)
f.b.completeBuildsManually = true
f.setMaxParallelUpdates(2)
Expand Down Expand Up @@ -628,6 +646,7 @@ func TestBuildControllerWontBuildManifestIfNoSlotsAvailable(t *testing.T) {
// are in progress (e.g. if there are 5 builds in progress and user sets
// maxParallelUpdates=3, nothing should explode.)
func TestCurrentlyBuildingMayExceedMaxParallelUpdates(t *testing.T) {
t.Parallel()
f := newTestFixture(t)
f.b.completeBuildsManually = true
f.setMaxParallelUpdates(3)
Expand Down Expand Up @@ -682,6 +701,7 @@ func TestCurrentlyBuildingMayExceedMaxParallelUpdates(t *testing.T) {
}

func TestDontStartBuildIfControllerAndEngineUnsynced(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

f.b.completeBuildsManually = true
Expand Down Expand Up @@ -719,6 +739,7 @@ func TestDontStartBuildIfControllerAndEngineUnsynced(t *testing.T) {
}

func TestErrorHandlingWithMultipleBuilds(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("TODO(nick): fix this")
}
Expand Down Expand Up @@ -768,6 +789,7 @@ func TestErrorHandlingWithMultipleBuilds(t *testing.T) {
}

func TestManifestsWithSameTwoImages(t *testing.T) {
t.Parallel()
f := newTestFixture(t)
m1, m2 := NewManifestsWithSameTwoImages(f)
f.Start([]model.Manifest{m1, m2})
Expand Down Expand Up @@ -815,6 +837,7 @@ func TestManifestsWithSameTwoImages(t *testing.T) {
}

func TestManifestsWithTwoCommonAncestors(t *testing.T) {
t.Parallel()
f := newTestFixture(t)
m1, m2 := NewManifestsWithTwoCommonAncestors(f)
f.Start([]model.Manifest{m1, m2})
Expand Down Expand Up @@ -871,6 +894,7 @@ func TestManifestsWithTwoCommonAncestors(t *testing.T) {
}

func TestLocalDependsOnNonWorkloadK8s(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

local1 := manifestbuilder.New(f, "local").
Expand All @@ -897,6 +921,7 @@ func TestLocalDependsOnNonWorkloadK8s(t *testing.T) {
}

func TestManifestsWithCommonAncestorAndTrigger(t *testing.T) {
t.Parallel()
f := newTestFixture(t)
m1, m2 := NewManifestsWithCommonAncestor(f)
f.Start([]model.Manifest{m1, m2})
Expand Down Expand Up @@ -924,6 +949,7 @@ func TestManifestsWithCommonAncestorAndTrigger(t *testing.T) {
}

func TestDisablingCancelsBuild(t *testing.T) {
t.Parallel()
f := newTestFixture(t)
manifest := manifestbuilder.New(f, "local").
WithLocalResource("sleep 10000", nil).
Expand All @@ -948,6 +974,7 @@ func TestDisablingCancelsBuild(t *testing.T) {
}

func TestCancelButton(t *testing.T) {
t.Parallel()
f := newTestFixture(t)
f.b.completeBuildsManually = true
f.useRealTiltfileLoader()
Expand Down Expand Up @@ -975,6 +1002,7 @@ local_resource('local', 'sleep 10000')
}

func TestCancelButtonClickedBeforeBuild(t *testing.T) {
t.Parallel()
f := newTestFixture(t)
f.b.completeBuildsManually = true
f.useRealTiltfileLoader()
Expand Down Expand Up @@ -1014,6 +1042,7 @@ local_resource('local', 'sleep 10000')
}

func TestBuildControllerK8sFileDependencies(t *testing.T) {
t.Parallel()
f := newTestFixture(t)

kt := k8s.MustTarget("fe", testyaml.SanchoYAML).
Expand Down
14 changes: 14 additions & 0 deletions internal/engine/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package engine

import (
"io"
"os"
"testing"

"github.com/tilt-dev/tilt/internal/controllers"
)

func TestMain(m *testing.M) {
controllers.InitKlog(io.Discard)
os.Exit(m.Run())
}
Loading