(t *testing.T)
| 357 | } |
| 358 | |
| 359 | func TestParseLogFileWithCodexRustFormat(t *testing.T) { |
| 360 | // Create a temporary log file with the new Rust-based Codex format |
| 361 | tmpDir := testutil.TempDir(t, "test-*") |
| 362 | logFile := filepath.Join(tmpDir, "test-codex-rust.log") |
| 363 | |
| 364 | // This simulates the new Rust format from the Codex engine |
| 365 | logContent := `2025-01-15T10:30:00.123456Z INFO codex: Starting codex execution |
| 366 | 2025-01-15T10:30:00.234567Z DEBUG codex_core: Initializing MCP servers |
| 367 | 2025-01-15T10:30:01.123456Z INFO codex: Session initialized |
| 368 | thinking |
| 369 | Let me fetch the list of pull requests first to see what we're working with. |
| 370 | 2025-01-15T10:30:02.123456Z DEBUG codex_exec: Executing tool call |
| 371 | tool github.list_pull_requests({"state": "closed", "per_page": 5}) |
| 372 | 2025-01-15T10:30:03.456789Z DEBUG codex_core: Tool execution started |
| 373 | 2025-01-15T10:30:04.567890Z INFO codex: github.list_pull_requests(...) success in 2.1s |
| 374 | thinking |
| 375 | Now I need to get details for each PR to write a comprehensive summary. |
| 376 | 2025-01-15T10:30:05.123456Z DEBUG codex_exec: Executing tool call |
| 377 | tool github.get_pull_request({"pull_number": 123}) |
| 378 | 2025-01-15T10:30:06.234567Z INFO codex: github.get_pull_request(...) success in 0.8s |
| 379 | 2025-01-15T10:30:07.345678Z DEBUG codex_core: Processing response |
| 380 | thinking |
| 381 | I have all the information I need. Let me create a summary issue. |
| 382 | 2025-01-15T10:30:08.456789Z DEBUG codex_exec: Executing tool call |
| 383 | tool safe_outputs.create_issue({"title": "PR Summary", "body": "..."}) |
| 384 | 2025-01-15T10:30:09.567890Z INFO codex: safe_outputs.create_issue(...) success in 1.2s |
| 385 | 2025-01-15T10:30:10.123456Z DEBUG codex_core: Workflow completing |
| 386 | tokens used: 15234 |
| 387 | 2025-01-15T10:30:10.234567Z INFO codex: Execution complete` |
| 388 | |
| 389 | err := os.WriteFile(logFile, []byte(logContent), 0644) |
| 390 | if err != nil { |
| 391 | t.Fatalf("Failed to create test log file: %v", err) |
| 392 | } |
| 393 | |
| 394 | // Test with Codex engine to parse new Rust format |
| 395 | codexEngine := workflow.NewCodexEngine() |
| 396 | metrics, err := parseLogFileWithEngine(logFile, codexEngine, false, false) |
| 397 | if err != nil { |
| 398 | t.Fatalf("parseLogFileWithEngine failed: %v", err) |
| 399 | } |
| 400 | |
| 401 | // Check token usage extraction from Rust format |
| 402 | expectedTokens := 15234 |
| 403 | if metrics.TokenUsage != expectedTokens { |
| 404 | t.Errorf("Expected token usage %d, got %d", expectedTokens, metrics.TokenUsage) |
| 405 | } |
| 406 | |
| 407 | // Check turns extraction from thinking sections (new Rust format uses standalone "thinking" lines) |
| 408 | expectedTurns := 3 // Three thinking sections in the test data |
| 409 | if metrics.Turns != expectedTurns { |
| 410 | t.Errorf("Expected turns %d, got %d", expectedTurns, metrics.Turns) |
| 411 | } |
| 412 | |
| 413 | // Check tool calls extraction from new Rust format |
| 414 | expectedToolCount := 3 |
| 415 | if len(metrics.ToolCalls) != expectedToolCount { |
| 416 | t.Errorf("Expected %d tool calls, got %d", expectedToolCount, len(metrics.ToolCalls)) |
nothing calls this directly
no test coverage detected