summaryrefslogtreecommitdiff
path: root/internal/executor/executor_test.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-04-04 09:18:52 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-04-04 09:18:52 +0000
commit2917c580ae3eab093e9e655ccdf210030b7b9d1f (patch)
tree2d1d89af605a19a3b70c3eee5972921c083be364 /internal/executor/executor_test.go
parentd4aeb496a883fa20194ae01d127535494e684812 (diff)
fix: executor checker — close race, test flakiness, checker report for all failure states
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/executor/executor_test.go')
-rw-r--r--internal/executor/executor_test.go23
1 files changed, 13 insertions, 10 deletions
diff --git a/internal/executor/executor_test.go b/internal/executor/executor_test.go
index f5ac8b8..e947606 100644
--- a/internal/executor/executor_test.go
+++ b/internal/executor/executor_test.go
@@ -2097,12 +2097,19 @@ func TestPool_CheckerSpawned_OnReady(t *testing.T) {
pool.Submit(context.Background(), tk)
<-pool.Results() // wait for original task to finish
- // Give the async spawnCheckerTask goroutine a moment to run.
- time.Sleep(200 * time.Millisecond)
-
- checker, err := store.GetCheckerTask("checker-spawn-1")
- if err != nil {
- t.Fatalf("GetCheckerTask: %v", err)
+ // Poll until the async spawnCheckerTask goroutine has written the checker task.
+ var checker *task.Task
+ var err error
+ deadline := time.Now().Add(5 * time.Second)
+ for time.Now().Before(deadline) {
+ checker, err = store.GetCheckerTask("checker-spawn-1")
+ if err != nil {
+ t.Fatalf("GetCheckerTask: %v", err)
+ }
+ if checker != nil {
+ break
+ }
+ time.Sleep(50 * time.Millisecond)
}
if checker == nil {
t.Fatal("expected a checker task to be created, got nil")
@@ -2143,10 +2150,8 @@ func TestPool_CheckerNotSpawned_ForSubtask(t *testing.T) {
func TestPool_CheckerPass_AutoAcceptsTask(t *testing.T) {
store := testStore(t)
// Two-phase: first runner succeeds (original task), second also succeeds (checker).
- callCount := 0
runner := &mockRunner{
onRun: func(t *task.Task, e *storage.Execution) error {
- callCount++
return nil // both original and checker succeed
},
}
@@ -2179,10 +2184,8 @@ func TestPool_CheckerPass_AutoAcceptsTask(t *testing.T) {
func TestPool_CheckerFail_AttachesReport(t *testing.T) {
store := testStore(t)
- callCount := 0
runner := &mockRunner{
onRun: func(t *task.Task, e *storage.Execution) error {
- callCount++
if t.CheckerForTaskID != "" {
return fmt.Errorf("test suite failed: 3 failures")
}