From 93f1e94098f7377def596afeae5cf0e71ba5ebae Mon Sep 17 00:00:00 2001 From: PJ Date: Mon, 1 Jun 2026 21:55:53 +0530 Subject: [PATCH] test(runner): MaxSteps stops after exactly N steps --- internal/runner/runner_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/internal/runner/runner_test.go b/internal/runner/runner_test.go index 43fe75d..5d8e37c 100644 --- a/internal/runner/runner_test.go +++ b/internal/runner/runner_test.go @@ -137,6 +137,29 @@ func TestRunner_HappyPathStepsAndTraces(t *testing.T) { } } +func TestRunner_MaxStepsStopsAfterExactlyNSteps(t *testing.T) { + state := newHarness(t) + + const maxSteps = 3 + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + // A long duration ensures MaxSteps, not the deadline, ends the run. + summary, err := Run(ctx, Options{ + Duration: time.Hour, + IdleTimeout: 10 * time.Millisecond, + MaxSteps: maxSteps, + Driver: state.mock, + Verifier: state.verifier, + TraceWriter: state.writer, + }) + if err != nil { + t.Fatalf("Run: %v", err) + } + if summary.Steps != maxSteps { + t.Errorf("expected exactly %d steps, got %d", maxSteps, summary.Steps) + } +} + func TestRunner_ViolationSurfacesInSummary(t *testing.T) { state := newHarnessWithSpec(t, violationSpec)