05ae530442
Install current verified harness releases inside Docker, preserve persistent accounts and settings, and provide separate interactive and pipeline model defaults with terminal onboarding and fuzzy pickers. Add Docker-aware authoring transport, Pi stage execution, bounded workflow controls, reliable final-result readback and usage settlement, and finite short-lived CLI pipe draining. Keep dated installation evidence and packaged authoring guidance consistent. Verified with a real Docker installation, both harness stages and interactive authors, the built-in plan/implement/review starter, independent host race/vet checks, installer tests, and packaged skill tests. Generated release receipts stay ignored in clean checkouts.
59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
package harness
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// TestIsTerminalRejectsCharacterDevicesAndPipes pins the true-TTY check: /dev/null
|
|
// is a character device but not a terminal, so choose-model must fail fast there
|
|
// instead of hanging until a subprocess timeout.
|
|
func TestIsTerminalRejectsCharacterDevicesAndPipes(t *testing.T) {
|
|
devnull, err := os.OpenFile(os.DevNull, os.O_RDWR, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer devnull.Close()
|
|
if isTerminal(devnull) {
|
|
t.Fatalf("%s counted as a terminal", os.DevNull)
|
|
}
|
|
readEnd, writeEnd, err := os.Pipe()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer readEnd.Close()
|
|
defer writeEnd.Close()
|
|
if isTerminal(readEnd) || isTerminal(writeEnd) {
|
|
t.Fatal("pipe counted as a terminal")
|
|
}
|
|
if isTerminal(struct{}{}) {
|
|
t.Fatal("non-file counted as a terminal")
|
|
}
|
|
}
|
|
|
|
func TestPickFailsFastOnDevNullAndPipeStreams(t *testing.T) {
|
|
devnull, err := os.OpenFile(os.DevNull, os.O_RDWR, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer devnull.Close()
|
|
// A short deadline keeps a TTY-detection regression from hanging the suite.
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
defer cancel()
|
|
if _, err := Pick(ctx, Selection{Title: "Model", Options: []string{"a/b"}}, devnull, devnull); err == nil || !strings.Contains(err.Error(), "requires a terminal") {
|
|
t.Fatalf("devnull picker error = %v", err)
|
|
}
|
|
readEnd, writeEnd, err := os.Pipe()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer readEnd.Close()
|
|
defer writeEnd.Close()
|
|
if _, err := Pick(ctx, Selection{Title: "Model", Options: []string{"a/b"}}, readEnd, writeEnd); err == nil || !strings.Contains(err.Error(), "requires a terminal") {
|
|
t.Fatalf("pipe picker error = %v", err)
|
|
}
|
|
}
|