From ff347b854017d915f44324c6a51b116bc88435c0 Mon Sep 17 00:00:00 2001 From: "Jason T. Greene" Date: Wed, 13 Sep 2023 23:51:05 -0500 Subject: [PATCH] tabs -> spaces Signed-off-by: Jason T. Greene --- test/client_test.go | 130 ++++++++++++++++++++++---------------------- test/suite_test.go | 10 ++-- 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/test/client_test.go b/test/client_test.go index 44d155c..207f8a9 100644 --- a/test/client_test.go +++ b/test/client_test.go @@ -4,104 +4,104 @@ package e2e import ( - "os" - "os/exec" - "path/filepath" - "time" - - "github.com/n1hility/winquit/pkg/winquit" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + "os" + "os/exec" + "path/filepath" + "time" + + "github.com/n1hility/winquit/pkg/winquit" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" ) var WINQUIT_PATH = filepath.Join("..", "bin", "winquit.exe") var _ = Describe("perquisites", func() { - It("winquit binary is built", func() { - _, err := os.Stat(WINQUIT_PATH) - Expect(err).ShouldNot(HaveOccurred()) - }) + It("winquit binary is built", func() { + _, err := os.Stat(WINQUIT_PATH) + Expect(err).ShouldNot(HaveOccurred()) + }) }) var _ = Describe("client", func() { - It("request quit should kill thidparty(winver) process", func() { - cmd := exec.Command("winver") - verifyRequestQuit(cmd, 5, true) - }) + It("request quit should kill thidparty(winver) process", func() { + cmd := exec.Command("winver") + verifyRequestQuit(cmd, 5, true) + }) }) var _ = Describe("client", func() { - It("request quit kills winquit simple server", func() { - cmd := exec.Command(WINQUIT_PATH, "simple-server") - verifyRequestQuit(cmd, 5, true) - }) + It("request quit kills winquit simple server", func() { + cmd := exec.Command(WINQUIT_PATH, "simple-server") + verifyRequestQuit(cmd, 5, true) + }) }) var _ = Describe("client", func() { - It("request quit kills winquit multi-server", func() { - cmd := exec.Command(WINQUIT_PATH, "multi-server") - verifyRequestQuit(cmd, 5, true) - }) + It("request quit kills winquit multi-server", func() { + cmd := exec.Command(WINQUIT_PATH, "multi-server") + verifyRequestQuit(cmd, 5, true) + }) }) var _ = Describe("client", func() { - It("request quit kills winquit signal server", func() { - cmd := exec.Command(WINQUIT_PATH, "signal-server") - verifyRequestQuit(cmd, 5, true) - }) + It("request quit kills winquit signal server", func() { + cmd := exec.Command(WINQUIT_PATH, "signal-server") + verifyRequestQuit(cmd, 5, true) + }) }) var _ = Describe("client", func() { - It("request quit does not kill winquit hang server", func() { - cmd := exec.Command(WINQUIT_PATH, "hang-server") - verifyRequestQuit(cmd, 1, false) - }) + It("request quit does not kill winquit hang server", func() { + cmd := exec.Command(WINQUIT_PATH, "hang-server") + verifyRequestQuit(cmd, 1, false) + }) }) var _ = Describe("client", func() { - It("demand quit does kill winquit hang server", func() { - cmd := exec.Command(WINQUIT_PATH, "hang-server") - verifyForceQuit(cmd, 1, 5, true) - }) + It("demand quit does kill winquit hang server", func() { + cmd := exec.Command(WINQUIT_PATH, "hang-server") + verifyForceQuit(cmd, 1, 5, true) + }) }) func verifyRequestQuit(cmd *exec.Cmd, timeout int, outcome bool) { - verifyStart(cmd) - winquit.RequestQuit(cmd.Process.Pid) - verifyExit(cmd, timeout, outcome) + verifyStart(cmd) + winquit.RequestQuit(cmd.Process.Pid) + verifyExit(cmd, timeout, outcome) } func verifyForceQuit(cmd *exec.Cmd, forceTimeout int, timeout int, outcome bool) { - verifyStart(cmd) - winquit.QuitProcess(cmd.Process.Pid, time.Duration(forceTimeout)*time.Second) - verifyExit(cmd, timeout, outcome) + verifyStart(cmd) + winquit.QuitProcess(cmd.Process.Pid, time.Duration(forceTimeout)*time.Second) + verifyExit(cmd, timeout, outcome) } func verifyStart(cmd *exec.Cmd) { - err := cmd.Start() - Expect(err).ShouldNot(HaveOccurred()) - time.Sleep(100 * time.Millisecond) - Expect(cmd.ProcessState).To(BeNil()) - _, err = os.FindProcess(cmd.Process.Pid) - Expect(err).ShouldNot(HaveOccurred()) + err := cmd.Start() + Expect(err).ShouldNot(HaveOccurred()) + time.Sleep(100 * time.Millisecond) + Expect(cmd.ProcessState).To(BeNil()) + _, err = os.FindProcess(cmd.Process.Pid) + Expect(err).ShouldNot(HaveOccurred()) } func verifyExit(cmd *exec.Cmd, timeout int, outcome bool) { - completed := make(chan bool) - go func() { - cmd.Wait() - completed <- true - }() - - result := false - select { - case <-completed: - result = true - case <-time.After(time.Duration(timeout) * time.Second): - } - - Expect(result).To(Equal(outcome)) - if !outcome { - cmd.Process.Kill() - } + completed := make(chan bool) + go func() { + cmd.Wait() + completed <- true + }() + + result := false + select { + case <-completed: + result = true + case <-time.After(time.Duration(timeout) * time.Second): + } + + Expect(result).To(Equal(outcome)) + if !outcome { + cmd.Process.Kill() + } } diff --git a/test/suite_test.go b/test/suite_test.go index 759f659..6d9387d 100644 --- a/test/suite_test.go +++ b/test/suite_test.go @@ -4,13 +4,13 @@ package e2e import ( - "testing" + "testing" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" ) func TestTest(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Test Suite") + RegisterFailHandler(Fail) + RunSpecs(t, "Test Suite") }