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) } }
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()) } }
func gitDescribe(dir string) (string, error) { os.Chdir(dir) script := "git describe" cmd := sh.Command{script} out, err := cmd.Run() return out, err }
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 }