tg.run(append([]string{"test"}, files...)...)
}
+func TestNonCanonicalImportPaths(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
+ tg.runFail("build", "canonical/d")
+ tg.grepStderr("package canonical/d", "did not report canonical/d")
+ tg.grepStderr("imports canonical/b", "did not report canonical/b")
+ tg.grepStderr("imports canonical/a/: non-canonical", "did not report canonical/a/")
+}
+
func TestVersionControlErrorMessageIncludesCorrectDirectory(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
}
}
+ if origPath != cleanImport(origPath) {
+ p.Error = &PackageError{
+ ImportStack: stk.copy(),
+ Err: fmt.Sprintf("non-canonical import path: %q should be %q", origPath, pathpkg.Clean(origPath)),
+ }
+ p.Incomplete = true
+ }
+
return p
}
+func cleanImport(path string) string {
+ orig := path
+ path = pathpkg.Clean(path)
+ if strings.HasPrefix(orig, "./") && path != ".." && path != "." && !strings.HasPrefix(path, "../") {
+ path = "./" + path
+ }
+ return path
+}
+
var isDirCache = map[string]bool{}
func isDir(path string) bool {