Пример #1
0
func Run(executable string, args ...string) *cmdtest.Session {
	cmd := exec.Command(executable, args...)

	sess, err := cmdtest.StartWrapped(cmd, teeStdout, teeStderr)
	if err != nil {
		panic(err)
	}

	return sess
}
func (runner *CLIRunner) start(command string, timestamp int, message string) *cmdtest.Session {
	cmd := exec.Command("hm9000", command, fmt.Sprintf("--config=%s", runner.configPath))
	cmd.Env = append(os.Environ(), fmt.Sprintf("HM9000_FAKE_TIME=%d", timestamp))

	var session *cmdtest.Session
	var err error
	if runner.verbose {
		session, err = cmdtest.StartWrapped(cmd, teeToStdout, teeToStdout)
	} else {
		session, err = cmdtest.Start(cmd)
	}

	Ω(err).ShouldNot(HaveOccurred())

	Ω(session).Should(SayWithTimeout(message, 5*time.Second))

	return session
}
func (runner *CLIRunner) StartSession(command string, timestamp int, extraArgs ...string) *cmdtest.Session {
	args := []string{command, fmt.Sprintf("--config=%s", runner.configPath)}
	args = append(args, extraArgs...)

	cmd := exec.Command("hm9000", args...)
	cmd.Env = append(os.Environ(), fmt.Sprintf("HM9000_FAKE_TIME=%d", timestamp))

	var session *cmdtest.Session
	var err error

	if runner.verbose {
		session, err = cmdtest.StartWrapped(cmd, teeToStdout, teeToStdout)
	} else {
		session, err = cmdtest.Start(cmd)
	}

	Ω(err).ShouldNot(HaveOccurred())

	return session
}
Пример #4
0
  overlay_directory_in_rootfs /home rw
  overlay_directory_in_rootfs /sbin rw
  overlay_directory_in_rootfs /var rw

  mkdir -p tmp/rootfs/tmp
  chmod 777 tmp/rootfs/tmp
  overlay_directory_in_rootfs /tmp rw
}

setup_fs
`), 0755)

		setUpRoot := exec.Command(path.Join(libDir, "set-up-root.sh"), os.Getenv("GARDEN_TEST_ROOTFS"))
		setUpRoot.Dir = containerDir

		setUpRootSession, err := cmdtest.StartWrapped(setUpRoot, outWrapper, outWrapper)
		Expect(err).ToNot(HaveOccurred())
		Expect(setUpRootSession).To(ExitWith(0))

		err = copyFile(shmTest, path.Join(mntDir, "sbin", "shmtest"))
		Expect(err).ToNot(HaveOccurred())

		socketPath = path.Join(runDir, "wshd.sock")

		wshdCommand = exec.Command(
			wshd,
			"--run", runDir,
			"--lib", libDir,
			"--root", mntDir,
			"--title", "test wshd",
		)
Пример #5
0
package runner

import (
	"fmt"
	"io"
	"os"
	"os/exec"
	"strings"

	"github.com/vito/cmdtest"
)

var SessionStarter = func(cmd *exec.Cmd) (*cmdtest.Session, error) {
	return cmdtest.StartWrapped(cmd, teeStdout, teeStderr)
}

func Run(executable string, args ...string) *cmdtest.Session {
	cmd := exec.Command(executable, args...)

	if verboseOutputEnabled() {
		fmt.Println("\n", "> ", strings.Join(cmd.Args, " "))
	}

	sess, err := SessionStarter(cmd)
	if err != nil {
		panic(err)
	}

	return sess
}
Пример #6
0
	// TODO: move to cmdtest
	err = os.Chmod(gocartPath, 0755)
	if err != nil {
		panic(err)
	}

	var installCmd *exec.Cmd
	var gopath string

	teeToStdout := func(w io.Writer) io.Writer {
		return io.MultiWriter(w, os.Stdout)
	}

	installing := func() *cmdtest.Session {
		sess, err := cmdtest.StartWrapped(installCmd, teeToStdout, teeToStdout)
		Expect(err).ToNot(HaveOccurred())

		return sess
	}

	install := func() {
		sess := installing()

		Expect(sess).To(Say("OK"))
		Expect(sess).To(ExitWith(0))
	}

	BeforeEach(func() {
		installCmd = exec.Command(gocartPath, "install")