1//+build CI 2 3package main 4 5import ( 6 "io/ioutil" 7 "os" 8 "os/exec" 9 "path/filepath" 10 "runtime" 11 "testing" 12) 13 14func TestBootstrap(t *testing.T) { 15 dir, err := ioutil.TempDir("", "") 16 if err != nil { 17 t.Fatal(err) 18 } 19 defer os.RemoveAll(dir) 20 21 s, err := run("go", "run", "bootstrap.go") 22 if err != nil { 23 t.Fatal(s) 24 } 25 name := "mage" 26 if runtime.GOOS == "windows" { 27 name += ".exe" 28 } 29 if _, err := os.Stat(filepath.Join(os.Getenv("GOPATH"), "bin", name)); err != nil { 30 t.Fatal(err) 31 } 32} 33 34func run(cmd string, args ...string) (string, error) { 35 c := exec.Command(cmd, args...) 36 c.Env = os.Environ() 37 b, err := c.CombinedOutput() 38 return string(b), err 39} 40