-
Notifications
You must be signed in to change notification settings - Fork 162
/
run.go
43 lines (33 loc) · 889 Bytes
/
run.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package testutils
import (
"fmt"
"os/exec"
"time"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega/gexec"
)
func BuildExecutable() error {
return BuildExecutableForArch("")
}
func BuildExecutableForArch(arch string) error {
buildArg := "./../bin/build"
if arch != "" {
buildArg = buildArg + "-" + arch
}
session, err := RunCommand(buildArg)
if session.ExitCode() != 0 {
return fmt.Errorf("Failed to build bosh:\nstdout:\n%s\nstderr:\n%s", session.Out.Contents(), session.Err.Contents())
}
return err
}
func RunCommand(cmd string, args ...string) (*gexec.Session, error) {
return RunComplexCommand(exec.Command(cmd, args...))
}
func RunComplexCommand(cmd *exec.Cmd) (*gexec.Session, error) {
session, err := gexec.Start(cmd, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
if err != nil {
return nil, err
}
session.Wait(120 * time.Second)
return session, nil
}