mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
This commit addresses the remaining Minor issues from PR #94 code review: Minor #12: Unicode Symbol Compatibility - Added CODEAGENT_ASCII_MODE environment variable support - When set to "true", uses ASCII symbols: PASS/WARN/FAIL - Default behavior (unset or "false"): Unicode symbols ✓/⚠️/✗ - Updated help text to document the environment variable - Added tests for both ASCII and Unicode modes Implementation: - executor.go:514: New getStatusSymbols() function - executor.go:531: Dynamic symbol selection in generateFinalOutputWithMode - main.go:34: useASCIIMode variable declaration - main.go:495: Environment variable documentation in help - executor_concurrent_test.go:292: Tests for ASCII mode - main_integration_test.go:89: Parser updated for both symbol formats Minor #13: Performance Optimization - Reduce Repeated String Operations - Optimized Message parsing to split only once per task result - Added *FromLines() variants of all extractor functions - Original extract*() functions now wrap *FromLines() for compatibility - Reduces memory allocations and CPU usage in parallel execution Implementation: - utils.go:300: extractCoverageFromLines() - utils.go:390: extractFilesChangedFromLines() - utils.go:455: extractTestResultsFromLines() - utils.go:551: extractKeyOutputFromLines() - main.go:255: Single split with reuse: lines := strings.Split(...) Backward Compatibility: - All original extract*() functions preserved - Tests updated to handle both symbol formats - No breaking changes to public API Test Results: - All tests pass: go test ./... (40.164s) - ASCII mode verified: PASS/WARN/FAIL symbols display correctly - Unicode mode verified: ✓/⚠️/✗ symbols remain default - Performance: Single split per Message instead of 4+ Usage Examples: # Unicode mode (default) ./codeagent-wrapper --parallel < tasks.txt # ASCII mode (for terminals without Unicode support) CODEAGENT_ASCII_MODE=true ./codeagent-wrapper --parallel < tasks.txt Benefits: - Improved terminal compatibility across different environments - Reduced memory allocations in parallel execution - Better performance for large-scale parallel tasks - User choice between Unicode aesthetics and ASCII compatibility Related: #94 Generated with SWE-Agent.ai Co-Authored-By: SWE-Agent.ai <noreply@swe-agent.ai>
This commit is contained in:
@@ -289,6 +289,45 @@ func TestExecutorHelperCoverage(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("generateFinalOutputASCIIMode", func(t *testing.T) {
|
||||
t.Setenv("CODEAGENT_ASCII_MODE", "true")
|
||||
|
||||
results := []TaskResult{
|
||||
{TaskID: "ok", ExitCode: 0, Coverage: "92%", CoverageNum: 92, CoverageTarget: 90, KeyOutput: "done"},
|
||||
{TaskID: "warn", ExitCode: 0, Coverage: "80%", CoverageNum: 80, CoverageTarget: 90, KeyOutput: "did"},
|
||||
{TaskID: "bad", ExitCode: 2, Error: "boom"},
|
||||
}
|
||||
out := generateFinalOutput(results)
|
||||
|
||||
for _, sym := range []string{"PASS", "WARN", "FAIL"} {
|
||||
if !strings.Contains(out, sym) {
|
||||
t.Fatalf("ASCII mode should include %q, got: %s", sym, out)
|
||||
}
|
||||
}
|
||||
for _, sym := range []string{"✓", "⚠️", "✗"} {
|
||||
if strings.Contains(out, sym) {
|
||||
t.Fatalf("ASCII mode should not include %q, got: %s", sym, out)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("generateFinalOutputUnicodeMode", func(t *testing.T) {
|
||||
t.Setenv("CODEAGENT_ASCII_MODE", "false")
|
||||
|
||||
results := []TaskResult{
|
||||
{TaskID: "ok", ExitCode: 0, Coverage: "92%", CoverageNum: 92, CoverageTarget: 90, KeyOutput: "done"},
|
||||
{TaskID: "warn", ExitCode: 0, Coverage: "80%", CoverageNum: 80, CoverageTarget: 90, KeyOutput: "did"},
|
||||
{TaskID: "bad", ExitCode: 2, Error: "boom"},
|
||||
}
|
||||
out := generateFinalOutput(results)
|
||||
|
||||
for _, sym := range []string{"✓", "⚠️", "✗"} {
|
||||
if !strings.Contains(out, sym) {
|
||||
t.Fatalf("Unicode mode should include %q, got: %s", sym, out)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("executeConcurrentWrapper", func(t *testing.T) {
|
||||
orig := runCodexTaskFn
|
||||
defer func() { runCodexTaskFn = orig }()
|
||||
|
||||
Reference in New Issue
Block a user