provider: the Devin install tests' held installer gives up when its test ends, and writes the CLI without the test's t
TestSignInInstallsMissingCLI and TestMovedSignInAsBuiltIn hold their fake
installer on a channel the test closes only after its first checks. A
Fatal before that left the installer blocked for the rest of the package's
run. f3c098da8 fixed the same hold in the Grok sibling with a cleanup;
these two were already gated and kept the leak. The hold now also ends on
the test's cleanup, and the installer returns an error then.
The installsMissingCLI fake also called testenv.Program(t, ...) on the
sign-in's goroutine. Under load (~125) its test hit waitPast's 5s first,
and the fake's late t.Fatal panicked the whole package ("Fail in goroutine
after TestSignInInstallsMissingCLI has completed"). It now uses
testenv.WriteProgram and returns the error.
Ran:
- An injected t.Fatal right after StartSignIn / StartPluginSignIn, plus a
test that dumps goroutines a second later: on origin/main the fake is
still blocked at install_test.go:40; with this, nothing is left.
- -race -count=20 of both tests, 2 runs each beside origin/main at load
~125-140: green on both.
- gofmt -l; go vet, GOOS=linux and GOOS=windows go vet ./internal/provider.
This commit is contained in:
@@ -32,14 +32,25 @@ func TestSignInInstallsMissingCLI(t *testing.T) {
|
||||
return ""
|
||||
}
|
||||
t.Cleanup(func() { DevinExecutable = oldExe })
|
||||
release := make(chan struct{})
|
||||
// an early failure ends the test with the install still held: the
|
||||
// fake then gives up without touching the test that has gone
|
||||
release, ended := make(chan struct{}), make(chan struct{})
|
||||
t.Cleanup(func() { close(ended) })
|
||||
var ran string
|
||||
oldRun := runInstaller
|
||||
runInstaller = func(ctx context.Context, c agentCLI) ([]byte, error) {
|
||||
ran = c.sh
|
||||
<-release
|
||||
select {
|
||||
case <-release:
|
||||
case <-ended:
|
||||
return nil, errors.New("the test ended")
|
||||
}
|
||||
os.MkdirAll(filepath.Dir(exe), 0o755)
|
||||
testenv.Program(t, exe, "#!/bin/sh\nprintf 'Logged in (via Devin).\\n Email: dev@example.com\\n Tier: Devin Pro\\n'\n")
|
||||
// not testenv.Program: this runs on the sign-in's goroutine, which a
|
||||
// failed test can leave behind
|
||||
if err := testenv.WriteProgram(exe, "#!/bin/sh\nprintf 'Logged in (via Devin).\\n Email: dev@example.com\\n Tier: Devin Pro\\n'\n"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// as Devin's does: `devin setup` gives up on its sign-in without a terminal
|
||||
return []byte("Installed devin\nError: Login canceled\n"), errors.New("exit status 1")
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package provider
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -222,10 +223,17 @@ func TestMovedSignInAsBuiltIn(t *testing.T) {
|
||||
return ""
|
||||
}
|
||||
t.Cleanup(func() { DevinExecutable = oldExe })
|
||||
release := make(chan struct{})
|
||||
// an early failure ends the test with the install still held: the
|
||||
// fake then gives up without touching the test that has gone
|
||||
release, ended := make(chan struct{}), make(chan struct{})
|
||||
t.Cleanup(func() { close(ended) })
|
||||
oldRun := runInstaller
|
||||
runInstaller = func(ctx context.Context, c agentCLI) ([]byte, error) {
|
||||
<-release
|
||||
select {
|
||||
case <-release:
|
||||
case <-ended:
|
||||
return nil, errors.New("the test ended")
|
||||
}
|
||||
os.MkdirAll(filepath.Dir(exe), 0o755)
|
||||
return nil, testenv.WriteProgram(exe, "#!/bin/sh\n")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user