(t *testing.T)
| 169 | } |
| 170 | |
| 171 | func 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 := ` |
| 185 | import time |
| 186 | time.sleep(10) |
| 187 | print("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 | |
| 205 | func TestRuntime_SyntaxError(t *testing.T) { |
| 206 | runtime := NewPythonRuntime(nil) |
nothing calls this directly
no test coverage detected