mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-15 03:32:43 +08:00
fix: make forceKillDelay testable to prevent signal test timeout
将 forceKillDelay 从常量改为变量,在 TestRun_LoggerRemovedOnSignal 中设为 1 秒。 防止测试等待 3 秒超时,而子进程需要 5 秒才能被强制杀死的竞态条件。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,6 @@ const (
|
|||||||
version = "4.8.2"
|
version = "4.8.2"
|
||||||
defaultWorkdir = "."
|
defaultWorkdir = "."
|
||||||
defaultTimeout = 7200 // seconds
|
defaultTimeout = 7200 // seconds
|
||||||
forceKillDelay = 5 // seconds
|
|
||||||
codexLogLineLimit = 1000
|
codexLogLineLimit = 1000
|
||||||
stdinSpecialChars = "\n\\\"'`$"
|
stdinSpecialChars = "\n\\\"'`$"
|
||||||
stderrCaptureLimit = 4 * 1024
|
stderrCaptureLimit = 4 * 1024
|
||||||
@@ -41,6 +40,7 @@ var (
|
|||||||
buildCodexArgsFn = buildCodexArgs
|
buildCodexArgsFn = buildCodexArgs
|
||||||
commandContext = exec.CommandContext
|
commandContext = exec.CommandContext
|
||||||
jsonMarshal = json.Marshal
|
jsonMarshal = json.Marshal
|
||||||
|
forceKillDelay = 5 // seconds - made variable for testability
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config holds CLI configuration
|
// Config holds CLI configuration
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ func resetTestHooks() {
|
|||||||
buildCodexArgsFn = buildCodexArgs
|
buildCodexArgsFn = buildCodexArgs
|
||||||
commandContext = exec.CommandContext
|
commandContext = exec.CommandContext
|
||||||
jsonMarshal = json.Marshal
|
jsonMarshal = json.Marshal
|
||||||
|
forceKillDelay = 5
|
||||||
closeLogger()
|
closeLogger()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1286,6 +1287,9 @@ func TestRun_LoggerRemovedOnSignal(t *testing.T) {
|
|||||||
defer resetTestHooks()
|
defer resetTestHooks()
|
||||||
defer signal.Reset(syscall.SIGINT, syscall.SIGTERM)
|
defer signal.Reset(syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|
||||||
|
// Set shorter force kill delay for faster test
|
||||||
|
forceKillDelay = 1
|
||||||
|
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
t.Setenv("TMPDIR", tempDir)
|
t.Setenv("TMPDIR", tempDir)
|
||||||
logPath := filepath.Join(tempDir, fmt.Sprintf("codex-wrapper-%d.log", os.Getpid()))
|
logPath := filepath.Join(tempDir, fmt.Sprintf("codex-wrapper-%d.log", os.Getpid()))
|
||||||
|
|||||||
Reference in New Issue
Block a user