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

Function TestParseLogFileWithCodexRustFormat

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

Source from the content-addressed store, hash-verified

357}
358
359func 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
3662025-01-15T10:30:00.234567Z DEBUG codex_core: Initializing MCP servers
3672025-01-15T10:30:01.123456Z INFO codex: Session initialized
368thinking
369Let me fetch the list of pull requests first to see what we're working with.
3702025-01-15T10:30:02.123456Z DEBUG codex_exec: Executing tool call
371tool github.list_pull_requests({"state": "closed", "per_page": 5})
3722025-01-15T10:30:03.456789Z DEBUG codex_core: Tool execution started
3732025-01-15T10:30:04.567890Z INFO codex: github.list_pull_requests(...) success in 2.1s
374thinking
375Now I need to get details for each PR to write a comprehensive summary.
3762025-01-15T10:30:05.123456Z DEBUG codex_exec: Executing tool call
377tool github.get_pull_request({"pull_number": 123})
3782025-01-15T10:30:06.234567Z INFO codex: github.get_pull_request(...) success in 0.8s
3792025-01-15T10:30:07.345678Z DEBUG codex_core: Processing response
380thinking
381I have all the information I need. Let me create a summary issue.
3822025-01-15T10:30:08.456789Z DEBUG codex_exec: Executing tool call
383tool safe_outputs.create_issue({"title": "PR Summary", "body": "..."})
3842025-01-15T10:30:09.567890Z INFO codex: safe_outputs.create_issue(...) success in 1.2s
3852025-01-15T10:30:10.123456Z DEBUG codex_core: Workflow completing
386tokens used: 15234
3872025-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))

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