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:
pj committed 2026-08-22 21:39:22 +05:30
1 parent d9f96602d9
commit 577993b540
14 files changed
+233 -1282

No files matched your search

+2 -27
View File
@@ -3,7 +3,6 @@ package runner
import (
"bufio"
"bytes"
"context"
"encoding/json"
"os"
"path/filepath"
@@ -91,19 +90,7 @@ func TestGolden_TraceStreamIsReproducible(t *testing.T) {
state.verifier = mustSeededVerifier(t, fixtureSpec, goldenSeed)
state.mock.HierarchyJSON = `{"attributes":{"resource-id":"HomeScreen"},"children":[{"attributes":{"resource-id":"next","bounds":"[40,80,240,160]"},"children":[],"clickable":true,"enabled":true}]}`
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
_, err := Run(ctx, Options{
Duration: time.Hour,
IdleTimeout: 10 * time.Millisecond,
MaxSteps: goldenSteps,
Driver: state.mock,
Verifier: state.verifier,
TraceWriter: state.writer,
})
if err != nil {
t.Fatalf("Run: %v", err)
}
state.run(t, Options{IdleTimeout: 10 * time.Millisecond, MaxSteps: goldenSteps})
raw, err := os.ReadFile(filepath.Join(state.writer.Directory(), "trace.jsonl"))
if err != nil {
t.Fatal(err)
@@ -119,19 +106,7 @@ func TestGolden_ViolationSummaryIsReproducible(t *testing.T) {
state := newHarnessWithSpec(t, violationSpec)
state.verifier = mustSeededVerifier(t, violationSpec, goldenSeed)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
summary, err := Run(ctx, Options{
Duration: time.Hour,
IdleTimeout: 10 * time.Millisecond,
MaxSteps: goldenSteps,
Driver: state.mock,
Verifier: state.verifier,
TraceWriter: state.writer,
})
if err != nil {
t.Fatalf("Run: %v", err)
}
summary := state.run(t, Options{IdleTimeout: 10 * time.Millisecond, MaxSteps: goldenSteps})
var rendered bytes.Buffer
RenderSummary(&rendered, summary, "android")