not tracking unstarted sessions
diff --git a/gexec/session.go b/gexec/session.go index 1dd5068..987e472 100644 --- a/gexec/session.go +++ b/gexec/session.go
@@ -92,9 +92,9 @@ err := command.Start() if err == nil { go session.monitorForExit(exited) + trackedSessions = append(trackedSessions, session) } - trackedSessions = append(trackedSessions, session) return session, err }
diff --git a/gexec/session_test.go b/gexec/session_test.go index 5a7af74..f8018b8 100644 --- a/gexec/session_test.go +++ b/gexec/session_test.go
@@ -152,6 +152,25 @@ Eventually(session2).Should(Exit(128 + 9)) Eventually(session3).Should(Exit(128 + 9)) }) + + It("should not track unstarted sessions", func() { + _, err := Start(exec.Command("does not exist", "10000000"), GinkgoWriter, GinkgoWriter) + Ω(err).Should(HaveOccurred()) + + session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) + Ω(err).ShouldNot(HaveOccurred()) + + session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter) + Ω(err).ShouldNot(HaveOccurred()) + + Kill() + Ω(session2).ShouldNot(Exit(), "Should not exit immediately...") + Ω(session3).ShouldNot(Exit(), "Should not exit immediately...") + + Eventually(session2).Should(Exit(128 + 9)) + Eventually(session3).Should(Exit(128 + 9)) + }) + }) Describe("killAndWait", func() {