add black-box debug harness
This commit is contained in:
49
internal/harness/scenario_test.go
Normal file
49
internal/harness/scenario_test.go
Normal 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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user