tg.grepStderr("GOPATH entry is relative", "expected an error message rejecting relative GOPATH entries")
}
+// Issue 21928.
+func TestRejectBlankPathsInGOPATH(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+ sep := string(filepath.ListSeparator)
+ tg.setenv("GOPATH", " "+sep+filepath.Join(tg.pwd(), "testdata"))
+ tg.runFail("build", "go-cmd-test")
+ tg.grepStderr("GOPATH entry is relative", "expected an error message rejecting relative GOPATH entries")
+}
+
+// Issue 21928.
+func TestIgnoreEmptyPathsInGOPATH(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.creatingTemp("testdata/bin/go-cmd-test" + exeSuffix)
+ sep := string(filepath.ListSeparator)
+ tg.setenv("GOPATH", ""+sep+filepath.Join(tg.pwd(), "testdata"))
+ tg.run("install", "go-cmd-test")
+ tg.wantExecutable("testdata/bin/go-cmd-test"+exeSuffix, "go install go-cmd-test did not write to testdata/bin/go-cmd-test")
+}
+
// Issue 4104.
func TestGoTestWithPackageListedMultipleTimes(t *testing.T) {
tg := testgo(t)
fmt.Fprintf(os.Stderr, "warning: GOPATH set to GOROOT (%s) has no effect\n", gopath)
} else {
for _, p := range filepath.SplitList(gopath) {
+ // Some GOPATHs have empty directory elements - ignore them.
+ // See issue 21928 for details.
+ if p == "" {
+ continue
+ }
// Note: using HasPrefix instead of Contains because a ~ can appear
// in the middle of directory elements, such as /tmp/git-1.8.2~rc3
// or C:\PROGRA~1. Only ~ as a path prefix has meaning to the shell.