mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
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 <noreply@swe-agent.ai>
This commit is contained in:
@@ -643,10 +643,24 @@ func (f *fakeCmd) StdinContents() string {
|
|||||||
|
|
||||||
func createFakeCodexScript(t *testing.T, threadID, message string) string {
|
func createFakeCodexScript(t *testing.T, threadID, message string) string {
|
||||||
t.Helper()
|
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
|
// 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
|
// the process exits and closes the pipe. This prevents race conditions in CI
|
||||||
// where fast shell script execution can close stdout before parsing completes.
|
// 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
|
script := fmt.Sprintf(`#!/bin/sh
|
||||||
printf '%%s\n' '{"type":"thread.started","thread_id":"%s"}'
|
printf '%%s\n' '{"type":"thread.started","thread_id":"%s"}'
|
||||||
printf '%%s\n' '{"type":"item.completed","item":{"type":"agent_message","text":"%s"}}'
|
printf '%%s\n' '{"type":"item.completed","item":{"type":"agent_message","text":"%s"}}'
|
||||||
|
|||||||
Reference in New Issue
Block a user