mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 12:07:09 +00:00
test(runner): retire the scaffolding the package grew by copying
Four consolidations, no assertion changed and the same 217 tests passing:
harness gains run and tryRun, retiring 68 copies of context.WithTimeout plus
Run(ctx, Options{}) plus an error check. The seven sites whose error check said
something specific keep their own wording.
mock.FailurePlan retires six wrapper drivers that were the same seven-line
method with a different error constant. The three that need more than an error
on call N stay.
traceStepLine absorbs the 15 local trace-line declarations and readTraceLines is
now the only reader. No local copy disagreed with internal/trace about a JSON
tag. Three raw readers stay on purpose: one decodes a real trace.Step, one
snapshots bytes, one asserts on raw JSON text.
One embeddable base carries the five V8-path methods the five web fakes each
redeclared.
This commit is contained in:
1 parent
d9f96602d9
commit
577993b540
14 files changed
+233
-1282
No files matched your search
@@ -493,7 +493,7 @@ func newSeededVerifier(t *testing.T) *verifier.Verifier {
|
||||
func TestPickSourcesRejectsLLMWithoutSpecConfig(t *testing.T) {
|
||||
for name, activeDriver := range map[string]driver.DeviceDriver{
|
||||
"native": nil,
|
||||
"web": &webMockDriver{Driver: mockdriver.New()},
|
||||
"web": &webMockDriver{webDriverBase: webDriverBase{Driver: mockdriver.New()}},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
action, extractor, err := pickSources(Options{
|
||||
@@ -523,7 +523,7 @@ func TestPickSourcesOnWebComposesLLMWithWebExtractors(t *testing.T) {
|
||||
fake := newFakeOpenRouter(t)
|
||||
_, verifierInstance := newLLMSource(t, fake)
|
||||
action, extractor, err := pickSources(Options{
|
||||
Driver: &webMockDriver{Driver: mockdriver.New()},
|
||||
Driver: &webMockDriver{webDriverBase: webDriverBase{Driver: mockdriver.New()}},
|
||||
Verifier: verifierInstance,
|
||||
Generator: "llm",
|
||||
Logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
|
||||
@@ -541,7 +541,7 @@ func TestPickSourcesOnWebComposesLLMWithWebExtractors(t *testing.T) {
|
||||
|
||||
func TestPickSourcesOnWebSeededKeepsBothOnV8(t *testing.T) {
|
||||
action, extractor, err := pickSources(Options{
|
||||
Driver: &webMockDriver{Driver: mockdriver.New()},
|
||||
Driver: &webMockDriver{webDriverBase: webDriverBase{Driver: mockdriver.New()}},
|
||||
Verifier: newSeededVerifier(t),
|
||||
Generator: "seeded",
|
||||
Logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
|
||||
@@ -768,22 +768,13 @@ func TestRunner_EveryModelCallFailingIsNotACleanRun(t *testing.T) {
|
||||
state := newHarnessWithSpec(t, llmFixtureSpec)
|
||||
state.mock.HierarchyJSON = llmTreeJSON
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
summary, err := Run(ctx, Options{
|
||||
summary := state.run(t, Options{
|
||||
Duration: 30 * time.Second,
|
||||
IdleTimeout: 20 * time.Millisecond,
|
||||
MaxSteps: 3,
|
||||
Driver: state.mock,
|
||||
Verifier: state.verifier,
|
||||
TraceWriter: state.writer,
|
||||
Generator: "llm",
|
||||
LabelSource: verifier.LabelSourceVisibleText,
|
||||
Logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Run: %v", err)
|
||||
}
|
||||
|
||||
calls := readLLMCalls(t, state.writer.Directory())
|
||||
if len(calls) != 3 {
|
||||
@@ -845,22 +836,13 @@ func TestRunner_SetupActionsAreNotTheGeneratorDrivingTheApp(t *testing.T) {
|
||||
state := newHarnessWithSpec(t, llmLoginSetupSpec)
|
||||
state.mock.HierarchyJSON = llmTreeJSON
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
summary, err := Run(ctx, Options{
|
||||
summary := state.run(t, Options{
|
||||
Duration: 30 * time.Second,
|
||||
IdleTimeout: 20 * time.Millisecond,
|
||||
MaxSteps: 4,
|
||||
Driver: state.mock,
|
||||
Verifier: state.verifier,
|
||||
TraceWriter: state.writer,
|
||||
Generator: "llm",
|
||||
LabelSource: verifier.LabelSourceVisibleText,
|
||||
Logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Run: %v", err)
|
||||
}
|
||||
|
||||
wantOutcomes := []string{
|
||||
trace.LLMOutcomeSetupAction, trace.LLMOutcomeSetupAction,
|
||||
@@ -933,22 +915,13 @@ func TestRunner_SetupAndGeneratorBothDrivingIsAHealthyRun(t *testing.T) {
|
||||
fake.choice = tap.Index
|
||||
fake.chosenAction = tap.Description
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
summary, err := Run(ctx, Options{
|
||||
summary := state.run(t, Options{
|
||||
Duration: 30 * time.Second,
|
||||
IdleTimeout: 20 * time.Millisecond,
|
||||
MaxSteps: 4,
|
||||
Driver: state.mock,
|
||||
Verifier: state.verifier,
|
||||
TraceWriter: state.writer,
|
||||
Generator: "llm",
|
||||
LabelSource: verifier.LabelSourceVisibleText,
|
||||
Logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Run: %v", err)
|
||||
}
|
||||
|
||||
if summary.DispatchedActions != 4 {
|
||||
t.Errorf("DispatchedActions = %d, want 4: every step drove the app",
|
||||
|
||||
Reference in new issue
Block a user