diff --git a/worker2/action_test.go b/worker2/action_test.go index 63ca9ecd..e7c535ee 100644 --- a/worker2/action_test.go +++ b/worker2/action_test.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/stretchr/testify/assert" "testing" - "time" ) func TestExecSimple(t *testing.T) { @@ -191,6 +190,8 @@ func TestExecCancel(t *testing.T) { }, } + errCh := a.ErrorCh() + e := NewEngine() ctx, cancel := context.WithCancel(context.Background()) @@ -200,10 +201,13 @@ func TestExecCancel(t *testing.T) { e.Schedule(a) - time.Sleep(time.Second) cancel() e.Wait() + + err := <-errCh + + assert.ErrorIs(t, err, context.Canceled) } func TestExecDeps(t *testing.T) { diff --git a/worker2/engine.go b/worker2/engine.go index 859e1f54..a1778093 100644 --- a/worker2/engine.go +++ b/worker2/engine.go @@ -274,7 +274,8 @@ func (e *Execution) Start(ctx context.Context) error { e.suspendCh = make(chan struct{}) go func() { - e.errCh <- e.safeExec(ctx) + err := e.safeExec(ctx) + e.errCh <- err }() } else { e.resumeAckCh <- struct{}{}