MCPcopy Create free account
hub / github.com/astercloud/aster / TestRuntime_Timeout

Function TestRuntime_Timeout

pkg/tools/bridge/runtime_test.go:171–203  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

169}
170
171func TestRuntime_Timeout(t *testing.T) {
172 config := &RuntimeConfig{
173 Timeout: 1 * time.Second,
174 MaxOutput: 1024,
175 }
176
177 runtime := NewPythonRuntime(config)
178
179 if !runtime.IsAvailable() {
180 t.Skip("Python not available")
181 }
182
183 ctx := context.Background()
184 code := `
185import time
186time.sleep(10)
187print("done")
188`
189
190 result, err := runtime.Execute(ctx, code, nil)
191 if err != nil {
192 t.Fatalf("Execute returned error: %v", err)
193 }
194
195 // 应该超时失败
196 if result.Success {
197 t.Error("expected timeout failure")
198 }
199
200 if result.Error != "execution timeout" {
201 t.Errorf("expected timeout error, got: %s", result.Error)
202 }
203}
204
205func TestRuntime_SyntaxError(t *testing.T) {
206 runtime := NewPythonRuntime(nil)

Callers

nothing calls this directly

Calls 4

IsAvailableMethod · 0.95
ExecuteMethod · 0.95
NewPythonRuntimeFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected