hooks: harden timeout kill and add platform split

- Move runHook into build-tagged implementations (unix/windows) to keep unix syscalls off Windows builds.
- In unix implementation, guard nil Process, return wrapped kill errors except ESRCH, and document linkage to TestRunSync_KillsDescendants.
- On Windows, best-effort kill on timeout retains prior behavior.
- In tests, move testing.Short earlier and keep descendant-kill coverage on Linux.
This commit is contained in:
Ross Gardler
2025-12-16 22:38:45 -08:00
parent 1465f7bb1d
commit 6b0d0901d0
4 changed files with 131 additions and 65 deletions

View File

@@ -260,6 +260,10 @@ func TestRunSync_KillsDescendants(t *testing.T) {
t.Skip("TestRunSync_KillsDescendants requires Linux /proc")
}
if testing.Short() {
t.Skip("Skipping long-running descendant kill test in short mode")
}
tmpDir := t.TempDir()
hookPath := filepath.Join(tmpDir, HookOnCreate)
pidFile := filepath.Join(tmpDir, "child.pid")
@@ -279,10 +283,6 @@ func TestRunSync_KillsDescendants(t *testing.T) {
}
issue := &types.Issue{ID: "bd-test", Title: "Test"}
if testing.Short() {
t.Skip("Skipping long-running descendant kill test in short mode")
}
err := runner.RunSync(EventCreate, issue)
if err == nil {
t.Fatal("Expected RunSync to return an error on timeout")