summaryrefslogtreecommitdiff
path: root/src/pkg/go/build/build_test.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-06-30 15:34:22 +0200
committerOndřej Surý <ondrej@sury.org>2011-06-30 15:34:22 +0200
commitd39f5aa373a4422f7a5f3ee764fb0f6b0b719d61 (patch)
tree1833f8b72a4b3a8f00d0d143b079a8fcad01c6ae /src/pkg/go/build/build_test.go
parent8652e6c371b8905498d3d314491d36c58d5f68d5 (diff)
downloadgolang-upstream/58.tar.gz
Imported Upstream version 58upstream/58
Diffstat (limited to 'src/pkg/go/build/build_test.go')
-rw-r--r--src/pkg/go/build/build_test.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/pkg/go/build/build_test.go b/src/pkg/go/build/build_test.go
new file mode 100644
index 000000000..c543eddbd
--- /dev/null
+++ b/src/pkg/go/build/build_test.go
@@ -0,0 +1,57 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package build
+
+import (
+ "os"
+ "path/filepath"
+ "runtime"
+ "strings"
+ "testing"
+)
+
+var buildDirs = []string{
+ "pkg/path",
+ "cmd/gofix",
+ "pkg/big",
+ "pkg/go/build/cgotest",
+}
+
+func TestBuild(t *testing.T) {
+ out, err := filepath.Abs("_test/out")
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, d := range buildDirs {
+ if runtime.GOARCH == "arm" && strings.Contains(d, "/cgo") {
+ // no cgo for arm, yet.
+ continue
+ }
+ dir := filepath.Join(runtime.GOROOT(), "src", d)
+ testBuild(t, dir, out)
+ }
+}
+
+func testBuild(t *testing.T, dir, targ string) {
+ d, err := ScanDir(dir, true)
+ if err != nil {
+ t.Error(err)
+ return
+ }
+ defer os.Remove(targ)
+ cmds, err := d.Build(targ)
+ if err != nil {
+ t.Error(err)
+ return
+ }
+ for _, c := range cmds {
+ t.Log("Run:", c)
+ err = c.Run(dir)
+ if err != nil {
+ t.Error(c, err)
+ return
+ }
+ }
+}