Add scripttest-based integration tests (#59)

- Complete test coverage for all major bd commands:
  blocked, close, create, dep (add/remove/tree), export, help,
  import, init, list, quickstart, ready, show, stats, update, version
- Test data files validate command behavior and output
- Enables automated testing of full CLI workflows
This commit is contained in:
Travis Cline
2025-10-16 17:11:54 -07:00
committed by GitHub
parent 363cd3b4e6
commit b17fcdbb2a
20 changed files with 151 additions and 0 deletions

26
cmd/bd/scripttest_test.go Normal file
View File

@@ -0,0 +1,26 @@
package main
import (
"context"
"os/exec"
"testing"
"time"
"rsc.io/script"
"rsc.io/script/scripttest"
)
func TestScripts(t *testing.T) {
// Build the bd binary
exe := t.TempDir() + "/bd"
if err := exec.Command("go", "build", "-o", exe, ".").Run(); err != nil {
t.Fatal(err)
}
// Create minimal engine with default commands plus bd
engine := script.NewEngine()
engine.Cmds["bd"] = script.Program(exe, nil, 100*time.Millisecond)
// Run all tests
scripttest.Test(t, context.Background(), engine, nil, "testdata/*.txt")
}