1 // Copyright 2018 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.
14 "golang.org/x/tools/godoc/vfs"
15 "golang.org/x/tools/godoc/vfs/gatefs"
18 func TestNewDirTree(t *testing.T) {
19 fsGate := make(chan bool, 20)
20 rootfs := gatefs.New(vfs.OS(runtime.GOROOT()), fsGate)
22 fs.Bind("/", rootfs, "/", vfs.BindReplace)
25 // 3 levels deep is enough for testing
26 dir := c.newDirectory("/", 3)
31 func processDir(t *testing.T, dir *Directory) {
33 for _, d := range dir.Dirs {
34 list = append(list, d.Name)
35 // recursively process the lower level
39 if sort.StringsAreSorted(list) == false {
40 t.Errorf("list: %v is not sorted\n", list)
44 func BenchmarkNewDirectory(b *testing.B) {
46 b.Skip("not running tests requiring large file scan in short mode")
49 fsGate := make(chan bool, 20)
51 goroot := runtime.GOROOT()
52 rootfs := gatefs.New(vfs.OS(goroot), fsGate)
54 fs.Bind("/", rootfs, "/", vfs.BindReplace)
55 for _, p := range filepath.SplitList(build.Default.GOPATH) {
56 fs.Bind("/src/golang.org", gatefs.New(vfs.OS(p), fsGate), "/src/golang.org", vfs.BindAfter)
60 for tries := 0; tries < b.N; tries++ {
61 corpus := NewCorpus(fs)
62 corpus.newDirectory("/", -1)