(code string)
| 422 | result := &CodeExecResult{Language: "python"} |
| 423 | start := time.Now() |
| 424 | |
| 425 | pythonBin := findPython() |
| 426 | if pythonBin == "" { |
| 427 | return nil |
| 428 | } |
| 429 | |
| 430 | dir, err := os.MkdirTemp("", "ark-verify-*") |
| 431 | if err != nil { |
| 432 | return nil |
| 433 | } |
| 434 | defer os.RemoveAll(dir) |
| 435 | |
| 436 | filePath := filepath.Join(dir, "verify.py") |
| 437 | if err := os.WriteFile(filePath, []byte(code), 0644); err != nil { |
| 438 | return nil |
| 439 | } |
| 440 | |
| 441 | // Syntax check |
| 442 | syntaxCmd := exec.Command(pythonBin, "-m", "py_compile", filePath) |
| 443 | syntaxOutput, syntaxErr := syntaxCmd.CombinedOutput() |
| 444 | result.Duration = time.Since(start) |
| 445 | |
| 446 | if syntaxErr != nil { |
| 447 | result.Compiled = false |
| 448 | result.Error = cleanCompilerError(string(syntaxOutput)) |
| 449 | return result |
| 450 | } |
| 451 | result.Compiled = true |
| 452 | |
| 453 | // Run |
| 454 | result.Ran = runWithTimeout(dir, pythonBin, []string{filePath}, result, 10*time.Second) |
| 455 | |
| 456 | // Lint with basic checks |
| 457 | result.Linted = true |
| 458 | |
| 459 | return result |
| 460 | } |
| 461 | |
| 462 | func executeJavaScript(code string) *CodeExecResult { |
| 463 | result := &CodeExecResult{Language: "javascript"} |
| 464 | start := time.Now() |
| 465 | |
| 466 | if _, err := exec.LookPath("node"); err != nil { |
no test coverage detected