Skip to content

Commit

Permalink
fix: exit with the exit code from the first failed task
Browse files Browse the repository at this point in the history
The integration_test didn't catch this because it doesn't exercise
cmd/run. Perhaps in the future, a better integration test will shell
out.
  • Loading branch information
amonks committed Nov 2, 2023
1 parent 86932fc commit fbd820a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/run/first.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func (f *first[T]) set(val T) {
f.mu.Lock()
defer f.mu.Unlock()

f.hasVal = true
if !f.hasVal {
f.val = val
f.hasVal = true
}
}

Expand Down
17 changes: 17 additions & 0 deletions cmd/run/first_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"testing"
"github.com/stretchr/testify/assert"
)

func TestFirst(t *testing.T) {
f := first[string]{}
assert.Equal(t, f.get(), "")

f.set("one")
assert.Equal(t, f.get(), "one")

f.set("two")
assert.Equal(t, f.get(), "one")
}

0 comments on commit fbd820a

Please sign in to comment.