MCPcopy Create free account
hub / github.com/github/gh-aw / TestParseLogFileWithCodexTokenSumming

Function TestParseLogFileWithCodexTokenSumming

pkg/cli/logs_parsing_test.go:325–357  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

323}
324
325func TestParseLogFileWithCodexTokenSumming(t *testing.T) {
326 // Create a temporary log file with multiple Codex token entries
327 tmpDir := testutil.TempDir(t, "test-*")
328 logFile := filepath.Join(tmpDir, "test-codex-tokens.log")
329
330 // Simulate the exact Codex format from the issue
331 logContent := ` ]
332}
333[2025-08-13T04:38:03] tokens used: 32169
334[2025-08-13T04:38:06] codex
335I've posted the PR summary comment with analysis and recommendations. Let me know if you'd like to adjust any details or add further insights!
336[2025-08-13T04:38:06] tokens used: 28828
337[2025-08-13T04:38:10] Processing complete
338[2025-08-13T04:38:15] tokens used: 5000`
339
340 err := os.WriteFile(logFile, []byte(logContent), 0644)
341 if err != nil {
342 t.Fatalf("Failed to create test log file: %v", err)
343 }
344
345 // Test with Codex engine
346 codexEngine := workflow.NewCodexEngine()
347 metrics, err := parseLogFileWithEngine(logFile, codexEngine, false, false)
348 if err != nil {
349 t.Fatalf("parseLogFileWithEngine failed: %v", err)
350 }
351
352 // Check that all token entries are summed
353 expectedTokens := 32169 + 28828 + 5000 // 65997
354 if metrics.TokenUsage != expectedTokens {
355 t.Errorf("Expected summed token usage %d, got %d", expectedTokens, metrics.TokenUsage)
356 }
357}
358
359func TestParseLogFileWithCodexRustFormat(t *testing.T) {
360 // Create a temporary log file with the new Rust-based Codex format

Callers

nothing calls this directly

Calls 4

TempDirFunction · 0.92
NewCodexEngineFunction · 0.92
parseLogFileWithEngineFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected