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

Function TestBashTimeoutOverflowClamped

internal/tools/bash_test.go:166–178  ·  view source on GitHub ↗

TestBashTimeoutOverflowClamped: extreme floats must be clamped BEFORE the Duration multiply. `time.Duration(1e18) * time.Second` overflows int64 to a negative deadline, firing context.WithTimeout instantly: the command would "succeed" without running. Clamp up front to avoid it.

(t *testing.T)

Source from the content-addressed store, hash-verified

164// Duration multiply. `time.Duration(1e18) * time.Second` overflows int64 to a
165// negative deadline, firing context.WithTimeout instantly: the command would
166// "succeed" without running. Clamp up front to avoid it.
167func TestBashTimeoutOverflowClamped(t *testing.T) {
168 call := chmctx.ToolCall{
169 ID: "t3", Name: "bash",
170 Arguments: map[string]any{
171 "cmd": "echo ok",
172 "timeout_seconds": float64(1e18),
173 },
174 }
175 msg := Execute(context.Background(), call)
176 if !strings.Contains(msg.Content, "ok") {
177 t.Fatalf("overflow clamp: expected echo output, got %q", msg.Content)
178 }
179}
180
181// TestBashParentCancelMidRun: parent cancel mid-sleep returns "(cancelled)",

Callers

nothing calls this directly

Calls 1

ExecuteFunction · 0.85

Tested by

no test coverage detected