From 60900cbc13ab6832de96f040532a1ffa4461018c Mon Sep 17 00:00:00 2001 From: Gerard Louis Recinto Date: Fri, 23 Oct 2026 02:14:24 -0700 Subject: [PATCH] Stop the daemon orphan test from leaving a helper running on Windows The orphan test starts a helper that slept for 20 seconds after the test finished. On Windows go test cannot delete the test binary while a copy is running, so the unit tests step exited 1 with 'unlinkat sop-daemon.test.exe: Access is denied' even though every test passed. Shorten the helper to 2 seconds and wait for it in test cleanup. Thanks, Gerard Recinto --- cmd/sop-daemon/main_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/sop-daemon/main_test.go b/cmd/sop-daemon/main_test.go index b7bb68f36..2149bb43d 100644 --- a/cmd/sop-daemon/main_test.go +++ b/cmd/sop-daemon/main_test.go @@ -155,7 +155,7 @@ func TestMain(m *testing.M) { time.Sleep(time.Minute) os.Exit(0) case "sleep": - time.Sleep(20 * time.Second) + time.Sleep(2 * time.Second) os.Exit(0) } os.Exit(m.Run()) @@ -229,6 +229,9 @@ func Test_TokenIsNotPassedToCommands(t *testing.T) { func Test_TimeoutReturnsEvenIfAChildHoldsTheOutputOpen(t *testing.T) { cfg := testConfig(t) cfg.commandTimeout = 300 * time.Millisecond + // The orphaned helper outlives the request. On Windows go test cannot delete + // the test binary while any copy of it is running, so wait for it to exit. + t.Cleanup(func() { time.Sleep(3 * time.Second) }) start := time.Now() resp := postExec(t, cfg, map[string]string{"SOP_DAEMON_TEST_HELPER": "orphan"}) if elapsed := time.Since(start); elapsed > 8*time.Second {