Migrate run state and reference contracts to native execution

This commit is contained in:
2026-11-22 05:24:30 +00:00
parent 5cfcf10a8b
commit 936fc1e72a
7 changed files with 450 additions and 1765 deletions

View File

@@ -2,54 +2,25 @@ package cli
import (
"bytes"
"errors"
"os"
"strings"
"testing"
)
func TestConfigCommandsDoNotResolveRunState(t *testing.T) {
func TestConfigCommandsDoNotAllocateRunState(t *testing.T) {
for _, args := range [][]string{
{"config", "validate", "--config"},
{"pipelines", "list", "--config"},
{"config", "validate"}, {"config", "show"}, {"pipeline", "list"}, {"pipeline", "validate", "dnd-session"},
} {
name := strings.Join(args[:2], "-")
t.Run(name, func(t *testing.T) {
roots := newStateTestRoots(t)
opts := newStateTestHarness().options()
opts.UserCacheDir = func() (string, error) { return "", errors.New("state root must not be resolved") }
command := append([]string(nil), args...)
command = append(command, roots.config)
var stdout, stderr bytes.Buffer
code := RunWithOptions(command, &stdout, &stderr, opts)
if code != 0 {
t.Fatalf("code=%d stdout=%q stderr=%q", code, stdout.String(), stderr.String())
}
assertNoRunState(t, roots)
})
fixture := newStateRunFixture(t)
var stdout, stderr bytes.Buffer
command := append(append([]string(nil), args...), "--config", fixture.configPath)
code := RunWithOptions(command, &stdout, &stderr, fixture.options)
if code != 0 {
t.Fatalf("%v status=%d stdout=%q stderr=%q", args, code, stdout.String(), stderr.String())
}
assertAbsent(t, fixture.outputRoot)
assertAbsent(t, fixture.cacheRoot)
assertAbsent(t, fixture.debugRoot)
if len(fixture.client.requestsSnapshot()) != 0 {
t.Fatal("inspection invoked provider")
}
}
}
func replaceStateTestConfigLine(t *testing.T, path, old, new string) {
t.Helper()
data, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
text := replaceRequiredOnce(t, string(data), old, new)
if err := os.WriteFile(path, []byte(text), 0o600); err != nil {
t.Fatal(err)
}
}
func removeStateTestConfigLine(t *testing.T, path, line string) {
replaceStateTestConfigLine(t, path, line, "")
}
func assertNoRunState(t *testing.T, roots stateTestRoots) {
t.Helper()
assertAbsent(t, roots.output)
assertAbsent(t, roots.plans)
assertAbsent(t, roots.checkpoints)
assertAbsent(t, roots.debug)
}