MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestBashBoundsRunawayOutput

Function TestBashBoundsRunawayOutput

internal/tools/bash_test.go:52–70  ·  view source on GitHub ↗

TestBashBoundsRunawayOutput: a firehose command must not grow an unbounded buffer (the old CombinedOutput OOM-killed the whole TUI on `cat big.iso` well before the timeout could react). The capture keeps head+tail with an OMITTED marker between, mirroring ctx.Truncate's framing, and preserves the ve

(t *testing.T)

Source from the content-addressed store, hash-verified

50// well before the timeout could react). The capture keeps head+tail with an
51// OMITTED marker between, mirroring ctx.Truncate's framing, and preserves the
52// very first and very last bytes so the model still sees both ends.
53func TestBashBoundsRunawayOutput(t *testing.T) {
54 // ~3x the tail cap so the ring provably wraps.
55 n := 3 * bashOutputTail
56 out := Bash(context.Background(),
57 "printf 'START'; head -c "+strconv.Itoa(n)+" /dev/zero | tr '\\0' 'a'; printf 'END'",
58 30*time.Second)
59 if len(out) > bashOutputHead+bashOutputTail+300 {
60 t.Fatalf("output not bounded: %d bytes", len(out))
61 }
62 if !strings.HasPrefix(out, "START") {
63 t.Fatalf("head lost, output starts %q", out[:16])
64 }
65 if !strings.Contains(out, "END\n(output capped at capture:") {
66 t.Fatalf("tail or capture note lost, output ends %q", out[len(out)-80:])
67 }
68 if !strings.Contains(out, "OMITTED") {
69 t.Fatal("dropped middle must carry the seam marker")
70 }
71}
72
73// TestHeadTailBufferSmallOutputUntouched: output under the head cap must come

Callers

nothing calls this directly

Calls 1

BashFunction · 0.85

Tested by

no test coverage detected