]> Cypherpunks.ru repositories - gostls13.git/blob - test/fixedbugs/bug345.go
e291a5516784e8403e19f7e92fed96c86bbe0251
[gostls13.git] / test / fixedbugs / bug345.go
1 // +build !nacl,!plan9,!windows
2 // run
3
4 // Copyright 2011 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         "os"
13         "os/exec"
14         "path/filepath"
15 )
16
17 func main() {
18         // TODO: If we get rid of errchk, re-enable this test on Plan 9 and Windows.
19         errchk, err := filepath.Abs("errchk")
20         check(err)
21
22         err = os.Chdir(filepath.Join(".", "fixedbugs", "bug345.dir"))
23         check(err)
24
25         run("go", "tool", "compile", "io.go")
26         run(errchk, "go", "tool", "compile", "-e", "main.go")
27         os.Remove("io.o")
28 }
29
30 func run(name string, args ...string) {
31         cmd := exec.Command(name, args...)
32         out, err := cmd.CombinedOutput()
33         if err != nil {
34                 fmt.Println(string(out))
35                 fmt.Println(err)
36                 os.Exit(1)
37         }
38 }
39
40 func check(err error) {
41         if err != nil {
42                 fmt.Println(err)
43                 os.Exit(1)
44         }
45 }