diff options
Diffstat (limited to 'src/cmd/api/goapi_test.go')
| -rw-r--r-- | src/cmd/api/goapi_test.go | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/cmd/api/goapi_test.go b/src/cmd/api/goapi_test.go index 1a86c0ec7..b909c32b3 100644 --- a/src/cmd/api/goapi_test.go +++ b/src/cmd/api/goapi_test.go @@ -1,3 +1,5 @@ +// +build api_tool + // 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. @@ -8,8 +10,10 @@ import ( "bytes" "flag" "fmt" + "go/build" "io/ioutil" "os" + "os/exec" "path/filepath" "sort" "strings" @@ -33,12 +37,10 @@ func TestGolden(t *testing.T) { if !fi.IsDir() { continue } - w := NewWalker() - w.wantedPkg[fi.Name()] = true - w.root = "testdata/src/pkg" goldenFile := filepath.Join("testdata", "src", "pkg", fi.Name(), "golden.txt") - w.WalkPackage(fi.Name()) + w := NewWalker(nil, "testdata/src/pkg") + w.export(w.Import(fi.Name())) if *updateGolden { os.Remove(goldenFile) @@ -110,7 +112,7 @@ func TestCompareAPI(t *testing.T) { features: []string{"A", "C"}, exception: []string{"B"}, ok: true, - out: "~B\n", + out: "", }, { // http://golang.org/issue/4303 @@ -139,3 +141,28 @@ func TestCompareAPI(t *testing.T) { } } } + +func BenchmarkAll(b *testing.B) { + stds, err := exec.Command("go", "list", "std").Output() + if err != nil { + b.Fatal(err) + } + b.ResetTimer() + pkgNames := strings.Fields(string(stds)) + + for _, c := range contexts { + c.Compiler = build.Default.Compiler + } + + for i := 0; i < b.N; i++ { + for _, context := range contexts { + w := NewWalker(context, filepath.Join(build.Default.GOROOT, "src/pkg")) + for _, name := range pkgNames { + if name != "unsafe" && !strings.HasPrefix(name, "cmd/") { + w.export(w.Import(name)) + } + } + w.Features() + } + } +} |
