github.com/reiver/go@v0.0.0-20150109200633-1d0c7792f172/test/fixedbugs/bug248.go (about) 1 // +build !nacl,!plan9,!windows 2 // run 3 4 // Copyright 2009 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 package main 9 10 import ( 11 "fmt" 12 "go/build" 13 "os" 14 "os/exec" 15 "path/filepath" 16 ) 17 18 func main() { 19 a, err := build.ArchChar(build.Default.GOARCH) 20 check(err) 21 22 // TODO: If we get rid of errchk, re-enable this test on Windows. 23 errchk, err := filepath.Abs("errchk") 24 check(err) 25 26 err = os.Chdir(filepath.Join("fixedbugs", "bug248.dir")) 27 check(err) 28 29 run("go", "tool", a+"g", "bug0.go") 30 run("go", "tool", a+"g", "bug1.go") 31 run("go", "tool", a+"g", "bug2.go") 32 run(errchk, "go", "tool", a+"g", "-e", "bug3.go") 33 run("go", "tool", a+"l", "bug2."+a) 34 run(fmt.Sprintf(".%c%s.out", filepath.Separator, a)) 35 36 os.Remove("bug0." + a) 37 os.Remove("bug1." + a) 38 os.Remove("bug2." + a) 39 os.Remove(a + ".out") 40 } 41 42 func run(name string, args ...string) { 43 cmd := exec.Command(name, args...) 44 out, err := cmd.CombinedOutput() 45 if err != nil { 46 fmt.Println(string(out)) 47 fmt.Println(err) 48 os.Exit(1) 49 } 50 } 51 52 func check(err error) { 53 if err != nil { 54 fmt.Println(err) 55 os.Exit(1) 56 } 57 }