func spawn(args []string) { wirer := &iodaemon.Wirer{WithTty: *tty, WindowColumns: *windowColumns, WindowRows: *windowRows} daemon := &iodaemon.Daemon{WithTty: *tty} if err := iodaemon.Spawn(args[1], args[2:], *timeout, os.Stdout, wirer, daemon); err != nil { fmt.Fprintf(os.Stderr, "failed: %s", err) os.Exit(2) } os.Exit(0) }
AfterEach(func() { defer os.RemoveAll(tmpdir) Eventually(exited).Should(BeClosed()) By("tidying up the socket file") if _, err := os.Stat(socketPath); !os.IsNotExist(err) { Fail("socket file not cleaned up") } }) Context("spawning a process", func() { spawnProcess := func(args ...string) { go func() { iodaemon.Spawn(socketPath, args, time.Second, fakeOut, wirer, daemon) close(exited) }() } It("times out when no listeners connect", func() { spawnProcess("echo", "hello") Eventually(exited, "3s").Should(BeClosed()) }) It("reports back stdout", func() { spawnProcess("echo", "hello") _, linkStdout, _, err := createLink(socketPath) Expect(err).ToNot(HaveOccurred())