This makes ImportDir("$GOROOT/src/math", 0)
and Import("math", "", 0) equivalent. It was an
oversight that they were not before.
An upcoming change to the go command relies on
the two returning the same results.
Change-Id: I187da4830fae85f8dde673c22836ff2da6801047
Reviewed-on: https://go-review.googlesource.com/75290
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
p.Goroot = true
p.ImportPath = sub
p.Root = ctxt.GOROOT
+ setPkga() // p.ImportPath changed
goto Found
}
}
// Record it.
p.ImportPath = sub
p.Root = root
+ setPkga() // p.ImportPath changed
goto Found
}
}
t.Fatalf("error on failed import does not mention GOROOT/src/vendor directory:\n%s", e)
}
}
+
+func TestImportDirTarget(t *testing.T) {
+ testenv.MustHaveGoBuild(t) // really must just have source
+ ctxt := Default
+ ctxt.GOPATH = ""
+ p, err := ctxt.ImportDir(filepath.Join(ctxt.GOROOT, "src/path"), 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if p.PkgTargetRoot == "" || p.PkgObj == "" {
+ t.Errorf("p.PkgTargetRoot == %q, p.PkgObj == %q, want non-empty", p.PkgTargetRoot, p.PkgObj)
+ }
+}