if getTestDeps {
// Process test dependencies when -t is specified.
// (Don't get test dependencies for test dependencies.)
+ //
+ // We apply vendoredImportPath here. It's not
+ // needed for Imports, because it was done
+ // while loading the package.
for _, path := range p.TestImports {
+ if path == "C" {
+ continue
+ }
+ path, _ = vendoredImportPath(p, path)
download(path, p, stk, false)
}
for _, path := range p.XTestImports {
+ if path == "C" {
+ continue
+ }
+ path, _ = vendoredImportPath(p, path)
download(path, p, stk, false)
}
}
}
for _, pkg := range load(args) {
+ // We apply vendoredImportPath here for test imports.
+ // It's not needed for regular imports, because it was
+ // done while loading the package.
+ for i, path := range pkg.TestImports {
+ path, _ = vendoredImportPath(pkg, path)
+ pkg.TestImports[i] = path
+ }
+ for i, path := range pkg.XTestImports {
+ path, _ = vendoredImportPath(pkg, path)
+ pkg.XTestImports[i] = path
+ }
+
do(pkg)
}
}
}
return x
}
+
+func TestVendorGet(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.tempFile("src/v/m.go", `
+ package main
+ import ("fmt"; "vendor.org/p")
+ func main() {
+ fmt.Println(p.C)
+ }`)
+ tg.tempFile("src/v/m_test.go", `
+ package main
+ import ("fmt"; "testing"; "vendor.org/p")
+ func TestNothing(t *testing.T) {
+ fmt.Println(p.C)
+ }`)
+ tg.tempFile("src/v/vendor/vendor.org/p/p.go", `
+ package p
+ const C = 1`)
+ tg.setenv("GOPATH", tg.path("."))
+ tg.setenv("GO15VENDOREXPERIMENT", "1")
+ tg.cd(tg.path("src/v"))
+ tg.run("run", "m.go")
+ tg.run("test")
+ tg.run("list", "-f", "{{.Imports}}")
+ tg.grepStdout("v/vendor/vendor.org/p", "import not in vendor directory")
+ tg.run("list", "-f", "{{.TestImports}}")
+ tg.grepStdout("v/vendor/vendor.org/p", "test import not in vendor directory")
+ tg.run("get")
+ tg.run("get", "-t")
+}