(t *testing.T)
| 279 | } |
| 280 | |
| 281 | func TestParseLogFileWithCodexFormat(t *testing.T) { |
| 282 | // Create a temporary log file with the Codex output format from the issue |
| 283 | tmpDir := testutil.TempDir(t, "test-*") |
| 284 | logFile := filepath.Join(tmpDir, "test-codex.log") |
| 285 | |
| 286 | // This is the exact Codex format provided in the issue with thinking sections added |
| 287 | logContent := `[2025-08-13T00:24:45] Starting Codex workflow execution |
| 288 | [2025-08-13T00:24:50] thinking |
| 289 | I need to analyze the pull request details first. |
| 290 | [2025-08-13T00:24:50] codex |
| 291 | |
| 292 | I'm ready to generate a Codex PR summary, but I need the pull request number to fetch its details. Could you please share the PR number (and confirm the repo/owner if it isn't ` + "`github/gh-aw`" + `)? |
| 293 | [2025-08-13T00:24:50] thinking |
| 294 | Now I need to wait for the user's response. |
| 295 | [2025-08-13T00:24:50] tokens used: 13934 |
| 296 | [2025-08-13T00:24:55] Workflow completed successfully` |
| 297 | |
| 298 | err := os.WriteFile(logFile, []byte(logContent), 0644) |
| 299 | if err != nil { |
| 300 | t.Fatalf("Failed to create test log file: %v", err) |
| 301 | } |
| 302 | |
| 303 | // Test with Codex engine to parse Codex-specific logs |
| 304 | codexEngine := workflow.NewCodexEngine() |
| 305 | metrics, err := parseLogFileWithEngine(logFile, codexEngine, false, false) |
| 306 | if err != nil { |
| 307 | t.Fatalf("parseLogFileWithEngine failed: %v", err) |
| 308 | } |
| 309 | |
| 310 | // Check token usage extraction from Codex format |
| 311 | expectedTokens := 13934 |
| 312 | if metrics.TokenUsage != expectedTokens { |
| 313 | t.Errorf("Expected token usage %d, got %d", expectedTokens, metrics.TokenUsage) |
| 314 | } |
| 315 | |
| 316 | // Check turns extraction from thinking sections |
| 317 | expectedTurns := 2 // Two thinking sections in the test data |
| 318 | if metrics.Turns != expectedTurns { |
| 319 | t.Errorf("Expected turns %d, got %d", expectedTurns, metrics.Turns) |
| 320 | } |
| 321 | |
| 322 | // Duration is no longer extracted from logs - using GitHub API timestamps instead |
| 323 | } |
| 324 | |
| 325 | func TestParseLogFileWithCodexTokenSumming(t *testing.T) { |
| 326 | // Create a temporary log file with multiple Codex token entries |
nothing calls this directly
no test coverage detected