tg.grepStderr("case-insensitive import collision", "go build example/a/pkg example/a/Pkg did not report import collision")
}
+// Issue 17451, 17662.
+func TestSymlinkWarning(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.parallel()
+ tg.makeTempdir()
+ tg.setenv("GOPATH", tg.path("."))
+
+ tg.tempDir("src/example/xx")
+ tg.tempDir("yy/zz")
+ tg.tempFile("yy/zz/zz.go", "package zz\n")
+ if err := os.Symlink(tg.path("yy"), tg.path("src/example/xx/yy")); err != nil {
+ t.Skip("symlink failed: %v", err)
+ }
+ tg.run("list", "example/xx/z...")
+ tg.grepStdoutNot(".", "list should not have matched anything")
+ tg.grepStderr("matched no packages", "list should have reported that pattern matched no packages")
+ tg.grepStderrNot("symlink", "list should not have reported symlink")
+
+ tg.run("list", "example/xx/...")
+ tg.grepStdoutNot(".", "list should not have matched anything")
+ tg.grepStderr("matched no packages", "list should have reported that pattern matched no packages")
+ tg.grepStderr("ignoring symlink", "list should have reported symlink")
+}
+
// Issue 8181.
func TestGoGetDashTIssue8181(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
root += "cmd" + string(filepath.Separator)
}
filepath.Walk(root, func(path string, fi os.FileInfo, err error) error {
- if err != nil || !fi.IsDir() || path == src {
+ if err != nil || path == src {
return nil
}
+ want := true
// Avoid .foo, _foo, and testdata directory trees.
_, elem := filepath.Split(path)
if strings.HasPrefix(elem, ".") || strings.HasPrefix(elem, "_") || elem == "testdata" {
- return filepath.SkipDir
+ want = false
}
name := filepath.ToSlash(path[len(src):])
if pattern == "std" && (!isStandardImportPath(name) || name == "cmd") {
// The name "std" is only the standard library.
// If the name is cmd, it's the root of the command tree.
- return filepath.SkipDir
+ want = false
}
if !treeCanMatch(name) {
+ want = false
+ }
+
+ if !fi.IsDir() {
+ if fi.Mode()&os.ModeSymlink != 0 && want {
+ if target, err := os.Stat(path); err == nil && target.IsDir() {
+ fmt.Fprintf(os.Stderr, "warning: ignoring symlink %s\n", path)
+ }
+ }
+ return nil
+ }
+ if !want {
return filepath.SkipDir
}
+
if have[name] {
return nil
}