MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestBashHonorsAlreadyCancelledParent

Function TestBashHonorsAlreadyCancelledParent

internal/tools/bash_test.go:109–118  ·  view source on GitHub ↗

TestBashHonorsAlreadyCancelledParent: a pre-cancelled parent (Ctrl+C raced the dispatch) must report "(cancelled)", not "(empty command)" or, worse, spawn a fresh /bin/sh. The cancel must win even on the empty-cmd fast path.

(t *testing.T)

Source from the content-addressed store, hash-verified

107// the dispatch) must report "(cancelled)", not "(empty command)" or, worse,
108// spawn a fresh /bin/sh. The cancel must win even on the empty-cmd fast path.
109func TestBashHonorsAlreadyCancelledParent(t *testing.T) {
110 parent, cancel := context.WithCancel(context.Background())
111 cancel()
112 if got := Bash(parent, "", time.Second); got != "(cancelled)" {
113 t.Fatalf("pre-cancelled bash returned %q, want (cancelled)", got)
114 }
115 if got := Bash(parent, "echo nope", time.Second); got != "(cancelled)" {
116 t.Fatalf("pre-cancelled bash with command returned %q, want (cancelled)", got)
117 }
118}
119
120func TestBashTimeout(t *testing.T) {
121 out := Bash(context.Background(), "sleep 2", 100*time.Millisecond)

Callers

nothing calls this directly

Calls 1

BashFunction · 0.85

Tested by

no test coverage detected