(t *testing.T)
| 431 | } |
| 432 | |
| 433 | func TestParseLogFileWithCodexMixedFormats(t *testing.T) { |
| 434 | // Create a temporary log file with mixed old TypeScript and new Rust formats |
| 435 | tmpDir := testutil.TempDir(t, "test-*") |
| 436 | logFile := filepath.Join(tmpDir, "test-codex-mixed.log") |
| 437 | |
| 438 | // Mix both formats to test backward compatibility |
| 439 | logContent := `[2025-08-13T00:24:45] Starting Codex workflow execution |
| 440 | [2025-08-13T00:24:50] thinking |
| 441 | Old format thinking section |
| 442 | [2025-08-13T00:24:50] tool github.list_repos({"org": "test"}) |
| 443 | [2025-08-13T00:24:51] codex |
| 444 | Response from old format |
| 445 | 2025-01-15T10:30:00.123456Z INFO codex: Starting execution |
| 446 | thinking |
| 447 | New Rust format thinking section |
| 448 | tool github.create_issue({"title": "Test", "body": "Body"}) |
| 449 | 2025-01-15T10:30:05.567890Z INFO codex: github.create_issue(...) success in 1.2s |
| 450 | [2025-08-13T00:24:52] tokens used: 5000 |
| 451 | tokens used: 10000 |
| 452 | 2025-01-15T10:30:10.234567Z INFO codex: Execution complete` |
| 453 | |
| 454 | err := os.WriteFile(logFile, []byte(logContent), 0644) |
| 455 | if err != nil { |
| 456 | t.Fatalf("Failed to create test log file: %v", err) |
| 457 | } |
| 458 | |
| 459 | // Test with Codex engine to parse mixed formats |
| 460 | codexEngine := workflow.NewCodexEngine() |
| 461 | metrics, err := parseLogFileWithEngine(logFile, codexEngine, false, false) |
| 462 | if err != nil { |
| 463 | t.Fatalf("parseLogFileWithEngine failed: %v", err) |
| 464 | } |
| 465 | |
| 466 | // Check token usage is summed from both formats |
| 467 | expectedTokens := 15000 // 5000 + 10000 |
| 468 | if metrics.TokenUsage != expectedTokens { |
| 469 | t.Errorf("Expected token usage %d (summed from both formats), got %d", expectedTokens, metrics.TokenUsage) |
| 470 | } |
| 471 | |
| 472 | // Check turns from both formats |
| 473 | expectedTurns := 2 // One from old format, one from new format |
| 474 | if metrics.Turns != expectedTurns { |
| 475 | t.Errorf("Expected turns %d (from both formats), got %d", expectedTurns, metrics.Turns) |
| 476 | } |
| 477 | |
| 478 | // Check tool calls from both formats |
| 479 | expectedToolCount := 2 |
| 480 | if len(metrics.ToolCalls) != expectedToolCount { |
| 481 | t.Errorf("Expected %d tool calls, got %d", expectedToolCount, len(metrics.ToolCalls)) |
| 482 | } |
| 483 | |
| 484 | // Verify the specific tools were detected from both formats |
| 485 | toolNames := make(map[string]bool) |
| 486 | for _, tool := range metrics.ToolCalls { |
| 487 | toolNames[tool.Name] = true |
| 488 | } |
| 489 | |
| 490 | expectedTools := []string{"github_list_repos", "github_create_issue"} |
nothing calls this directly
no test coverage detected