chore: import upstream snapshot with attribution
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/zzet/gortex/internal/agents"
|
||||
)
|
||||
|
||||
// updateAgentRender regenerates the committed agent-render goldens.
|
||||
// Run: go test ./cmd/gortex -run TestAgentsRenderGolden -update-agent-render
|
||||
var updateAgentRender = flag.Bool("update-agent-render", false, "regenerate the agent-render drift-fence goldens")
|
||||
|
||||
const agentRenderDir = "testdata/agent-render"
|
||||
|
||||
// TestAgentsRenderGolden is the all-platform skill-render drift fence:
|
||||
// it renders every registered adapter and byte-compares the result
|
||||
// against a committed golden. Any change to an adapter's generated MCP
|
||||
// config, instructions, hooks, or routing blocks must be accompanied by
|
||||
// a regenerated golden, so cross-platform drift is reviewable in the
|
||||
// diff — not just for the Claude bundle.
|
||||
func TestAgentsRenderGolden(t *testing.T) {
|
||||
manifests, err := agents.RenderManifest(buildRegistry().All())
|
||||
if err != nil {
|
||||
t.Fatalf("render adapters: %v", err)
|
||||
}
|
||||
|
||||
if *updateAgentRender {
|
||||
if err := os.MkdirAll(agentRenderDir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for name, got := range manifests {
|
||||
if err := os.WriteFile(filepath.Join(agentRenderDir, name+".txt"), []byte(got), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
t.Logf("regenerated %d agent-render goldens", len(manifests))
|
||||
return
|
||||
}
|
||||
|
||||
for name, got := range manifests {
|
||||
golden := filepath.Join(agentRenderDir, name+".txt")
|
||||
want, err := os.ReadFile(golden)
|
||||
if err != nil {
|
||||
t.Errorf("%s: missing golden %s — regenerate with `go test ./cmd/gortex -run TestAgentsRenderGolden -update-agent-render`", name, golden)
|
||||
continue
|
||||
}
|
||||
if string(want) != got {
|
||||
t.Errorf("%s: rendered output drifted from %s.\nReview the change; if intended, regenerate goldens:\n go test ./cmd/gortex -run TestAgentsRenderGolden -update-agent-render", name, golden)
|
||||
}
|
||||
}
|
||||
|
||||
// A golden with no corresponding adapter means an adapter was
|
||||
// removed without dropping its golden — flag it.
|
||||
entries, err := os.ReadDir(agentRenderDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, e := range entries {
|
||||
name := strings.TrimSuffix(e.Name(), ".txt")
|
||||
if name == e.Name() {
|
||||
continue // not a .txt golden
|
||||
}
|
||||
if _, ok := manifests[name]; !ok {
|
||||
t.Errorf("stale golden %s has no matching adapter — delete it or restore the adapter", e.Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user