mirror of
https://github.com/golang/go
synced 2024-11-18 14:54:40 -07:00
imports: respect ignoredDirs for symlinks
Fixes golang/go#17916 Added tests. Change-Id: Ie44e4bcbec267b6c16249336c5d48bae86acc2b5 Reviewed-on: https://go-review.googlesource.com/33246 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
8b84dae173
commit
4c6345e8dc
@ -462,6 +462,9 @@ func shouldTraverse(dir string, fi os.FileInfo) bool {
|
||||
if !ts.IsDir() {
|
||||
return false
|
||||
}
|
||||
if skipDir(ts) {
|
||||
return false
|
||||
}
|
||||
|
||||
realParent, err := filepath.EvalSymlinks(dir)
|
||||
if err != nil {
|
||||
|
@ -889,6 +889,40 @@ var (
|
||||
t.Fatalf("results differ\nGOT:\n%s\nWANT:\n%s\n", got, output)
|
||||
}
|
||||
})
|
||||
|
||||
// Add a .goimportsignore and ensure it is respected.
|
||||
if err := ioutil.WriteFile(newGoPath+"/src/.goimportsignore", []byte("x/mypkg\n"), 0666); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
withEmptyGoPath(func() {
|
||||
build.Default.GOPATH = newGoPath
|
||||
|
||||
input := `package p
|
||||
|
||||
var (
|
||||
_ = fmt.Print
|
||||
_ = mypkg.Foo
|
||||
)
|
||||
`
|
||||
output := `package p
|
||||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
_ = fmt.Print
|
||||
_ = mypkg.Foo
|
||||
)
|
||||
`
|
||||
buf, err := Process(newGoPath+"/src/myotherpkg/toformat.go", []byte(input), &Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := string(buf); got != output {
|
||||
t.Fatalf("ignored results differ\nGOT:\n%s\nWANT:\n%s\n", got, output)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// Test for correctly identifying the name of a vendored package when it
|
||||
|
Loading…
Reference in New Issue
Block a user