Exemple #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)
	}
}
Exemple #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())
	}
}
Exemple #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
}
Exemple #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
}