Add message with program and arguments to helper_run.go output
@@ -10,14 +10,17 @@ import (
"github.com/onsi/gomega/gexec"
)
+func runningCmd(cmd *exec.Cmd) string {
+ prog := filepath.Base(cmd.Path)
+ return fmt.Sprintf("Running %s with args %v", prog, cmd.Args)
+}
+
func CmdRunner(program string, args ...string) *gexec.Session {
//prefix ginkgo verbose output with program name
- fmt.Fprintf(GinkgoWriter, "Running %s with args: %v \n", program, args)
-
prefix := fmt.Sprintf("[%s] ", filepath.Base(program))
prefixWriter := gexec.NewPrefixedWriter(prefix, GinkgoWriter)
-
command := exec.Command(program, args...)
+ fmt.Fprintln(GinkgoWriter, runningCmd(command))
session, err := gexec.Start(command, prefixWriter, prefixWriter)
Expect(err).NotTo(HaveOccurred())
return session
@@ -26,13 +29,13 @@ func CmdRunner(program string, args ...string) *gexec.Session {
// CmdShouldPass returns stdout if command succeeds
func CmdShouldPass(program string, args ...string) string {
session := CmdRunner(program, args...)
- Eventually(session).Should(gexec.Exit(0))
+ Eventually(session).Should(gexec.Exit(0), runningCmd(session.Command))
return string(session.Wait().Out.Contents())
}
// CmdShouldFail returns stderr if command fails
func CmdShouldFail(program string, args ...string) string {
session := CmdRunner(program, args...)
- Consistently(session).ShouldNot(gexec.Exit(0))
+ Consistently(session).ShouldNot(gexec.Exit(0), runningCmd(session.Command))
return string(session.Wait().Err.Contents())
}
