mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-25 19:05:13 +00:00
update third_party go/build to go1.6
This commit is contained in:
79
third_party/golang/go/build/build_test.go
vendored
79
third_party/golang/go/build/build_test.go
vendored
@@ -5,6 +5,7 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"internal/testenv"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -109,7 +110,6 @@ func TestMultiplePackageImport(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLocalDirectory(t *testing.T) {
|
||||
return // go1.3 not happy with this test.
|
||||
if runtime.GOOS == "darwin" {
|
||||
switch runtime.GOARCH {
|
||||
case "arm", "arm64":
|
||||
@@ -126,8 +126,8 @@ func TestLocalDirectory(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p.ImportPath != "k8s.io/kubernetes/third_party/golang/go/build" {
|
||||
t.Fatalf("ImportPath=%q, want %q", p.ImportPath, "k8s.io/kubernetes/third_party/golang/go/build")
|
||||
if p.ImportPath != "go/build" {
|
||||
t.Fatalf("ImportPath=%q, want %q", p.ImportPath, "go/build")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,6 @@ func TestMatchFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportCmd(t *testing.T) {
|
||||
return // go1.3 not happy with this test
|
||||
if runtime.GOOS == "darwin" {
|
||||
switch runtime.GOARCH {
|
||||
case "arm", "arm64":
|
||||
@@ -269,7 +268,7 @@ var expandSrcDirTests = []struct {
|
||||
|
||||
func TestExpandSrcDir(t *testing.T) {
|
||||
for _, test := range expandSrcDirTests {
|
||||
output := expandSrcDir(test.input, expandSrcDirPath)
|
||||
output, _ := expandSrcDir(test.input, expandSrcDirPath)
|
||||
if output != test.expected {
|
||||
t.Errorf("%q expands to %q with SRCDIR=%q when %q is expected", test.input, output, expandSrcDirPath, test.expected)
|
||||
} else {
|
||||
@@ -277,3 +276,73 @@ func TestExpandSrcDir(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestShellSafety(t *testing.T) {
|
||||
tests := []struct {
|
||||
input, srcdir, expected string
|
||||
result bool
|
||||
}{
|
||||
{"-I${SRCDIR}/../include", "/projects/src/issue 11868", "-I/projects/src/issue 11868/../include", true},
|
||||
{"-X${SRCDIR}/1,${SRCDIR}/2", "/projects/src/issue 11868", "-X/projects/src/issue 11868/1,/projects/src/issue 11868/2", true},
|
||||
{"-I/tmp -I/tmp", "/tmp2", "-I/tmp -I/tmp", false},
|
||||
{"-I/tmp", "/tmp/[0]", "-I/tmp", true},
|
||||
{"-I${SRCDIR}/dir", "/tmp/[0]", "-I/tmp/[0]/dir", false},
|
||||
}
|
||||
for _, test := range tests {
|
||||
output, ok := expandSrcDir(test.input, test.srcdir)
|
||||
if ok != test.result {
|
||||
t.Errorf("Expected %t while %q expands to %q with SRCDIR=%q; got %t", test.result, test.input, output, test.srcdir, ok)
|
||||
}
|
||||
if output != test.expected {
|
||||
t.Errorf("Expected %q while %q expands with SRCDIR=%q; got %q", test.expected, test.input, test.srcdir, output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestImportVendor(t *testing.T) {
|
||||
t.Skip("skipping; hpack has moved to internal for now; golang.org/issue/14047")
|
||||
testenv.MustHaveGoBuild(t) // really must just have source
|
||||
ctxt := Default
|
||||
ctxt.GOPATH = ""
|
||||
p, err := ctxt.Import("golang.org/x/net/http2/hpack", filepath.Join(ctxt.GOROOT, "src/net/http"), 0)
|
||||
if err != nil {
|
||||
t.Fatalf("cannot find vendored golang.org/x/net/http2/hpack from net/http directory: %v", err)
|
||||
}
|
||||
want := "vendor/golang.org/x/net/http2/hpack"
|
||||
if p.ImportPath != want {
|
||||
t.Fatalf("Import succeeded but found %q, want %q", p.ImportPath, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImportVendorFailure(t *testing.T) {
|
||||
testenv.MustHaveGoBuild(t) // really must just have source
|
||||
ctxt := Default
|
||||
ctxt.GOPATH = ""
|
||||
p, err := ctxt.Import("x.com/y/z", filepath.Join(ctxt.GOROOT, "src/net/http"), 0)
|
||||
if err == nil {
|
||||
t.Fatalf("found made-up package x.com/y/z in %s", p.Dir)
|
||||
}
|
||||
|
||||
e := err.Error()
|
||||
if !strings.Contains(e, " (vendor tree)") {
|
||||
t.Fatalf("error on failed import does not mention GOROOT/src/vendor directory:\n%s", e)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImportVendorParentFailure(t *testing.T) {
|
||||
testenv.MustHaveGoBuild(t) // really must just have source
|
||||
ctxt := Default
|
||||
ctxt.GOPATH = ""
|
||||
// This import should fail because the vendor/golang.org/x/net/http2 directory has no source code.
|
||||
p, err := ctxt.Import("golang.org/x/net/http2", filepath.Join(ctxt.GOROOT, "src/net/http"), 0)
|
||||
if err == nil {
|
||||
t.Fatalf("found empty parent in %s", p.Dir)
|
||||
}
|
||||
if p != nil && p.Dir != "" {
|
||||
t.Fatalf("decided to use %s", p.Dir)
|
||||
}
|
||||
e := err.Error()
|
||||
if !strings.Contains(e, " (vendor tree)") {
|
||||
t.Fatalf("error on failed import does not mention GOROOT/src/vendor directory:\n%s", e)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user