From c96193fca6ec8b778e2488b4e3b478ef9e35e7e6 Mon Sep 17 00:00:00 2001 From: cexll Date: Mon, 26 Jan 2026 20:37:55 +0800 Subject: [PATCH] fix: make integration tests Windows-compatible Generate platform-specific mock executables in tests: - Windows: codex.bat with @echo off - Unix: codex.sh with #!/bin/bash Fixes CI failures on windows-latest runner. Generated with SWE-Agent.ai Co-Authored-By: SWE-Agent.ai --- codeagent-wrapper/internal/app/main_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/codeagent-wrapper/internal/app/main_test.go b/codeagent-wrapper/internal/app/main_test.go index d50873e..aebce67 100644 --- a/codeagent-wrapper/internal/app/main_test.go +++ b/codeagent-wrapper/internal/app/main_test.go @@ -643,10 +643,24 @@ func (f *fakeCmd) StdinContents() string { func createFakeCodexScript(t *testing.T, threadID, message string) string { t.Helper() - scriptPath := filepath.Join(t.TempDir(), "codex.sh") + tempDir := t.TempDir() + // Add small sleep to ensure parser goroutine has time to read stdout before // the process exits and closes the pipe. This prevents race conditions in CI // where fast shell script execution can close stdout before parsing completes. + if runtime.GOOS == "windows" { + scriptPath := filepath.Join(tempDir, "codex.bat") + script := fmt.Sprintf("@echo off\r\n"+ + "echo {\"type\":\"thread.started\",\"thread_id\":\"%s\"}\r\n"+ + "echo {\"type\":\"item.completed\",\"item\":{\"type\":\"agent_message\",\"text\":\"%s\"}}\r\n"+ + "exit /b 0\r\n", threadID, message) + if err := os.WriteFile(scriptPath, []byte(script), 0o755); err != nil { + t.Fatalf("failed to create fake codex script: %v", err) + } + return scriptPath + } + + scriptPath := filepath.Join(tempDir, "codex.sh") script := fmt.Sprintf(`#!/bin/sh printf '%%s\n' '{"type":"thread.started","thread_id":"%s"}' printf '%%s\n' '{"type":"item.completed","item":{"type":"agent_message","text":"%s"}}'