Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion acceptance/internal/prepare_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ func startLocalServer(t *testing.T,

if shouldKillCaller(stub, killCounters, killCountersMu) {
killCaller(t, stub.Pattern, req.Headers)
return testserver.Response{StatusCode: http.StatusOK}
}

return stub.Response
Expand Down Expand Up @@ -266,6 +265,9 @@ func killCaller(t *testing.T, pattern string, headers http.Header) {
return
}

if !waitForProcessExit(pid, 2*time.Second) {
t.Logf("KillCaller: timed out waiting for PID %d to exit (pattern: %s)", pid, pattern)
}
t.Logf("KillCaller: killed PID %d (pattern: %s)", pid, pattern)
}

Expand Down
19 changes: 19 additions & 0 deletions acceptance/internal/process_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//go:build linux || darwin

package internal

import (
"syscall"
"time"
)

func waitForProcessExit(pid int, timeout time.Duration) bool {
deadline := time.Now().Add(timeout)
for time.Now().Before(deadline) {
if syscall.Kill(pid, 0) != nil {
return true
}
time.Sleep(10 * time.Millisecond)
}
return false
}
27 changes: 27 additions & 0 deletions acceptance/internal/process_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//go:build windows

package internal

import (
"time"

"golang.org/x/sys/windows"
)

func waitForProcessExit(pid int, timeout time.Duration) bool {
deadline := time.Now().Add(timeout)
for time.Now().Before(deadline) {
handle, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid))
if err != nil {
return true
}
var exitCode uint32
err = windows.GetExitCodeProcess(handle, &exitCode)
windows.CloseHandle(handle)
if err != nil || exitCode != uint32(windows.STATUS_PENDING) {
return true
}
time.Sleep(10 * time.Millisecond)
}
return false
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
golang.org/x/mod v0.31.0
golang.org/x/oauth2 v0.34.0
golang.org/x/sync v0.19.0
golang.org/x/sys v0.39.0 // indirect
golang.org/x/sys v0.39.0
golang.org/x/term v0.38.0
golang.org/x/text v0.32.0
gopkg.in/ini.v1 v1.67.0 // Apache 2.0
Expand Down