Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package agentruntime
|
|
|
|
import (
|
|
"errors"
|
|
"sync"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestCloseLocalProcessAttemptCanRetryAfterFailure(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
exited := false
|
|
attempts := 0
|
|
killErr := errors.New("injected kill failure")
|
|
waitDone := func(time.Duration) bool { return exited }
|
|
closeInput := func() error { return nil }
|
|
terminate := func() error { return nil }
|
|
kill := func() error {
|
|
attempts++
|
|
if attempts == 1 {
|
|
return killErr
|
|
}
|
|
exited = true
|
|
return nil
|
|
}
|
|
|
|
if err := closeLocalProcessAttempt(waitDone, closeInput, terminate, kill); !errors.Is(err, killErr) {
|
|
t.Fatalf("first close error = %v, want %v", err, killErr)
|
|
}
|
|
if err := closeLocalProcessAttempt(waitDone, closeInput, terminate, kill); err != nil {
|
|
t.Fatalf("retry close: %v", err)
|
|
}
|
|
if attempts != 2 {
|
|
t.Fatalf("kill attempts = %d, want 2", attempts)
|
|
}
|
|
}
|
|
|
|
func TestLocalProcessConnectionCloseIsConcurrentAndIdempotentAfterExit(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
done := make(chan struct{})
|
|
close(done)
|
|
connection := &localProcessConnection{
|
|
done: done,
|
|
closing: make(chan struct{}),
|
|
}
|
|
|
|
const callers = 8
|
|
errs := make(chan error, callers)
|
|
var wg sync.WaitGroup
|
|
for range callers {
|
|
wg.Add(1)
|
|
go func() {
|
|
defer wg.Done()
|
|
errs <- connection.Close()
|
|
}()
|
|
}
|
|
wg.Wait()
|
|
close(errs)
|
|
for err := range errs {
|
|
if err != nil {
|
|
t.Fatalf("Close: %v", err)
|
|
}
|
|
}
|
|
}
|