Exemplo n.º 1
0
func TestRun(t *testing.T) {
	cmd := sh.Command{"echo -n 12; echo 34"}
	out, _ := cmd.Run()
	if out != "1234" {
		t.Errorf("command(%s) should output 1234, but is: %#v", cmd.Text(), out)
	}
}
Exemplo n.º 2
0
func TestFoo(t *testing.T) {
	cmd := sh.Command{"foo"}
	_, err := cmd.Run()
	if err.Error() != "exit status 127" {
		t.Errorf("command(%s) should exit with 127, but is: %#v", cmd.Text(), err.Error())
	}
}
Exemplo n.º 3
0
func gitDescribe(dir string) (string, error) {
	os.Chdir(dir)
	script := "git describe"
	cmd := sh.Command{script}

	out, err := cmd.Run()
	return out, err
}
Exemplo n.º 4
0
func gitRev(dir string) (string, error) {
	os.Chdir(dir)

	script := "git rev-list --count --first-parent HEAD"
	cmd := sh.Command{script}
	out, err := cmd.Run()

	if err != nil {
		return "", err
	}

	return fmt.Sprintf("r%s", out), err
}