add black-box debug harness

This commit is contained in:
2026-05-14 16:37:46 +01:00
parent 8d4df5f683
commit 56e94ae032
18 changed files with 1274 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
package harness
import (
"os"
"path/filepath"
"testing"
)
func TestLoadScenario(t *testing.T) {
sc, err := LoadScenario(filepath.Join("scenarios", "spawn_process_via_palette.json"))
if err != nil {
t.Fatal(err)
}
if sc.Cols != 120 || sc.Rows != 40 {
t.Fatalf("default size = %dx%d, want 120x40", sc.Cols, sc.Rows)
}
if len(sc.Steps) == 0 {
t.Fatal("expected steps")
}
}
func TestHarnessScenarios(t *testing.T) {
if testing.Short() {
t.Skip("skipping end-to-end harness scenarios in short mode")
}
paths, err := filepath.Glob(filepath.Join("scenarios", "*.json"))
if err != nil {
t.Fatal(err)
}
if len(paths) == 0 {
t.Fatal("no scenarios")
}
for _, path := range paths {
path := path
t.Run(filepath.Base(path), func(t *testing.T) {
sc, err := LoadScenario(path)
if err != nil {
t.Fatal(err)
}
res, err := RunScenario(Options{Scenario: sc, PattermBin: os.Getenv("PATTERM_BIN")}, nil)
if err != nil {
if res.Artifact != "" {
t.Fatalf("%v\nartifact: %s", err, res.Artifact)
}
t.Fatal(err)
}
})
}
}