LEFT | RIGHT |
(no file at all) | |
| 1 // Copyright 2011 The Go Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style |
| 3 // license that can be found in the LICENSE file. |
| 4 |
| 5 package build |
| 6 |
| 7 import ( |
| 8 "os" |
| 9 "path/filepath" |
| 10 "runtime" |
| 11 "testing" |
| 12 ) |
| 13 |
| 14 var buildDirs = []string{ |
| 15 "pkg/path", |
| 16 "cmd/gofix", |
| 17 "pkg/big", |
| 18 "pkg/go/build/cgotest", |
| 19 } |
| 20 |
| 21 func TestBuild(t *testing.T) { |
| 22 out, err := filepath.Abs("_test/out") |
| 23 if err != nil { |
| 24 t.Fatal(err) |
| 25 } |
| 26 for _, d := range buildDirs { |
| 27 dir := filepath.Join(runtime.GOROOT(), "src", d) |
| 28 testBuild(t, dir, out) |
| 29 } |
| 30 } |
| 31 |
| 32 func testBuild(t *testing.T, dir, targ string) { |
| 33 d, err := ScanDir(dir, true) |
| 34 if err != nil { |
| 35 t.Error(err) |
| 36 return |
| 37 } |
| 38 defer os.Remove(targ) |
| 39 cmds, err := d.Build(targ) |
| 40 if err != nil { |
| 41 t.Error(err) |
| 42 return |
| 43 } |
| 44 for _, c := range cmds { |
| 45 t.Log("Run:", c) |
| 46 err = c.Run(dir) |
| 47 if err != nil { |
| 48 t.Error(c, err) |
| 49 return |
| 50 } |
| 51 } |
| 52 } |
LEFT | RIGHT |