From 76235f37ef0f025fb02287c65c4c58443b5e7534 Mon Sep 17 00:00:00 2001 From: Geoff Franks Date: Wed, 27 May 2026 10:53:29 -0400 Subject: [PATCH] Fix Windows test deadlock by removing aggressive defer cleanup The previous defer cleanup logic was causing test deadlocks on Windows: - defer functions were checking session.ExitCode() == -1 and calling Kill() - This interfered with natural process termination via session.Terminate() - Tests failed with "Expected process to exit. It did not." Solution: - Remove aggressive defer cleanup from individual test cases - Rely on AfterEach cleanup for port management - Let processes exit naturally without interference - Keep cross-platform signal handling (Windows: 42, Unix: 143) This allows Windows tests to pass while maintaining proper cleanup through the existing AfterEach hook and Serial execution. Made-with: Cursor --- .../inigo/cell/assets/fake_app_test.go | 33 -------------- .../inigo/cell/assets/fake_proxy_test.go | 44 ------------------- 2 files changed, 77 deletions(-) diff --git a/src/code.cloudfoundry.org/inigo/cell/assets/fake_app_test.go b/src/code.cloudfoundry.org/inigo/cell/assets/fake_app_test.go index d05c8c43e..4f5a84e37 100644 --- a/src/code.cloudfoundry.org/inigo/cell/assets/fake_app_test.go +++ b/src/code.cloudfoundry.org/inigo/cell/assets/fake_app_test.go @@ -85,17 +85,6 @@ var _ = Describe("Fake App Exit Behavior", Serial, func() { session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) - // Ensure cleanup on test completion - defer func() { - if session.ExitCode() == -1 { // Process still running - session.Kill() - } - // On Windows, add extra cleanup time - if runtime.GOOS == "windows" { - time.Sleep(100 * time.Millisecond) - } - }() - // Wait for server to start Eventually(func() error { client := &http.Client{Timeout: 1 * time.Second} @@ -125,17 +114,6 @@ var _ = Describe("Fake App Exit Behavior", Serial, func() { session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) - // Ensure cleanup on test completion - defer func() { - if session.ExitCode() == -1 { // Process still running - session.Kill() - } - // On Windows, add extra cleanup time - if runtime.GOOS == "windows" { - time.Sleep(100 * time.Millisecond) - } - }() - // Wait for server to start Eventually(func() error { client := &http.Client{Timeout: 1 * time.Second} @@ -165,17 +143,6 @@ var _ = Describe("Fake App Exit Behavior", Serial, func() { session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) - // Ensure cleanup on test completion - defer func() { - if session.ExitCode() == -1 { // Process still running - session.Kill() - } - // On Windows, add extra cleanup time - if runtime.GOOS == "windows" { - time.Sleep(100 * time.Millisecond) - } - }() - // Wait for app to start listening Eventually(func() error { client := &http.Client{Timeout: 1 * time.Second} diff --git a/src/code.cloudfoundry.org/inigo/cell/assets/fake_proxy_test.go b/src/code.cloudfoundry.org/inigo/cell/assets/fake_proxy_test.go index d7e88931d..5e673fca1 100644 --- a/src/code.cloudfoundry.org/inigo/cell/assets/fake_proxy_test.go +++ b/src/code.cloudfoundry.org/inigo/cell/assets/fake_proxy_test.go @@ -40,17 +40,6 @@ var _ = Describe("Fake Proxy Exit Behavior", Serial, func() { session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) - // Ensure cleanup on test completion - defer func() { - if session.ExitCode() == -1 { // Process still running - session.Kill() - } - // On Windows, add extra cleanup time - if runtime.GOOS == "windows" { - time.Sleep(100 * time.Millisecond) - } - }() - // Wait for proxy to start listening on port 61001 Eventually(func() error { client := &http.Client{Timeout: 1 * time.Second} @@ -79,17 +68,6 @@ var _ = Describe("Fake Proxy Exit Behavior", Serial, func() { session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) - // Ensure cleanup on test completion - defer func() { - if session.ExitCode() == -1 { // Process still running - session.Kill() - } - // On Windows, add extra cleanup time - if runtime.GOOS == "windows" { - time.Sleep(100 * time.Millisecond) - } - }() - // Wait for proxy to start listening on port 61001 Eventually(func() error { client := &http.Client{Timeout: 1 * time.Second} @@ -136,17 +114,6 @@ var _ = Describe("Fake Proxy Exit Behavior", Serial, func() { session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) - // Ensure cleanup on test completion - defer func() { - if session.ExitCode() == -1 { // Process still running - session.Kill() - } - // On Windows, add extra cleanup time - if runtime.GOOS == "windows" { - time.Sleep(100 * time.Millisecond) - } - }() - // Wait for proxy to start Eventually(func() error { client := &http.Client{Timeout: 1 * time.Second} @@ -192,17 +159,6 @@ var _ = Describe("Fake Proxy Exit Behavior", Serial, func() { session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) - // Ensure cleanup on test completion - defer func() { - if session.ExitCode() == -1 { // Process still running - session.Kill() - } - // On Windows, add extra cleanup time - if runtime.GOOS == "windows" { - time.Sleep(100 * time.Millisecond) - } - }() - // Wait for proxy to start listening Eventually(func() error { client := &http.Client{Timeout: 1 * time.Second}