Ejemplo n.º 1
0
func (s *FakeCmdStarter) Start(reporter internal.Reporter, executable string, args ...string) (*gexec.Session, error) {
	output := s.ToReturn[s.TotalCallsToStart].Output
	if output == "" {
		output = `\{\}`
	}
	sleepTime := s.ToReturn[s.TotalCallsToStart].SleepTime
	exitCode := s.ToReturn[s.TotalCallsToStart].ExitCode
	err := s.ToReturn[s.TotalCallsToStart].Err

	s.TotalCallsToStart += 1

	callToStart := callToStartMethod{
		Executable: executable,
		Args:       args,
		Reporter:   reporter,
	}
	s.CalledWith = append(s.CalledWith, callToStart)

	reporter.Report(time.Now(), exec.Command(executable, args...))
	cmd := exec.Command(
		"bash",
		"-c",
		fmt.Sprintf(
			"echo %s; sleep %d; exit %d",
			output,
			sleepTime,
			exitCode,
		),
	)
	session, _ := gexec.Start(cmd, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
	return session, err
}
func (r *CommandStarter) Start(reporter internal.Reporter, executable string, args ...string) (*gexec.Session, error) {
	cmd := exec.Command(executable, args...)
	reporter.Report(time.Now(), cmd)

	return gexec.Start(cmd, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
}