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

Function TestParseLogFileWithCodexMixedFormats

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

Source from the content-addressed store, hash-verified

431}
432
433func 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
441Old format thinking section
442[2025-08-13T00:24:50] tool github.list_repos({"org": "test"})
443[2025-08-13T00:24:51] codex
444Response from old format
4452025-01-15T10:30:00.123456Z INFO codex: Starting execution
446thinking
447New Rust format thinking section
448tool github.create_issue({"title": "Test", "body": "Body"})
4492025-01-15T10:30:05.567890Z INFO codex: github.create_issue(...) success in 1.2s
450[2025-08-13T00:24:52] tokens used: 5000
451tokens used: 10000
4522025-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"}

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