Skip to content

Commit

Permalink
engine: handle tiltignore and team loading correctly if execution fai…
Browse files Browse the repository at this point in the history
…led (#3523)

fixes #3514
  • Loading branch information
nicks committed Jun 29, 2020
1 parent 652d5cc commit 55b08f1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/engine/upper.go
Expand Up @@ -484,6 +484,16 @@ func handleConfigsReloaded(
// Retroactively scrub secrets
state.LogStore.ScrubSecretsStartingAt(newSecrets, event.CheckpointAtExecStart)

// Add tiltignore if it exists, even if execution failed.
if event.TiltIgnoreContents != "" || event.Err != nil {
state.TiltIgnoreContents = event.TiltIgnoreContents
}

// Add team id if it exists, even if execution failed.
if event.TeamID != "" || event.Err != nil {
state.TeamID = event.TeamID
}

// if the ConfigsReloadedAction came from a unit test, there might not be a current build
if !b.Empty() {
b.FinishTime = event.FinishTime
Expand Down Expand Up @@ -552,10 +562,8 @@ func handleConfigsReloaded(
// TODO(maia): update ConfigsManifest with new ConfigFiles/update watches
state.ManifestDefinitionOrder = newDefOrder
state.ConfigFiles = event.ConfigFiles
state.TiltIgnoreContents = event.TiltIgnoreContents

state.Features = event.Features
state.TeamID = event.TeamID
state.TelemetrySettings = event.TelemetrySettings
state.VersionSettings = event.VersionSettings
state.AnalyticsTiltfileOpt = event.AnalyticsTiltfileOpt
Expand Down
32 changes: 32 additions & 0 deletions internal/engine/upper_test.go
Expand Up @@ -3463,6 +3463,38 @@ update_settings(max_parallel_updates=123)
})
}

// https://github.com/tilt-dev/tilt/issues/3514
func TestTiltignoreRespectedOnError(t *testing.T) {
f := newTestFixture(t)
defer f.TearDown()

f.WriteFile("Tiltfile", `local("echo hi > a.txt")
read_file('a.txt')
fail('x')`)
f.WriteFile(".tiltignore", "a.txt")

f.Init(InitAction{
EngineMode: store.EngineModeUp,
TiltfilePath: f.JoinPath("Tiltfile"),
TerminalMode: store.TerminalModeHUD,
StartTime: f.Now(),
})

f.WaitUntil(".tiltignore processed", func(es store.EngineState) bool {
return strings.Contains(es.TiltIgnoreContents, "a.txt")
})

f.WriteFile(".tiltignore", "a.txt\nb.txt\n")
f.fsWatcher.Events <- watch.NewFileEvent(f.JoinPath("Tiltfile"))

f.WaitUntil(".tiltignore processed", func(es store.EngineState) bool {
return strings.Contains(es.TiltIgnoreContents, "b.txt")
})

err := f.Stop()
assert.NoError(t, err)
}

type testFixture struct {
*tempdir.TempDirFixture
t *testing.T
Expand Down

0 comments on commit 55b08f1

Please sign in to comment.