From 0ed91a755789db6b9db7d0c553d3c45634fd3eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 24 Oct 2016 18:59:18 +0300 Subject: [PATCH] build, internal/build: sort out vendor quircks --- build/ci.go | 16 +++++++++++++++- internal/build/util.go | 11 +---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/build/ci.go b/build/ci.go index cf43969f6c..e28d98be74 100644 --- a/build/ci.go +++ b/build/ci.go @@ -178,6 +178,7 @@ func goTool(subcmd string, args ...string) *exec.Cmd { cmd := exec.Command(gocmd, subcmd) cmd.Args = append(cmd.Args, args...) cmd.Env = []string{ + "GO15VENDOREXPERIMENT=1", "GOPATH=" + build.GOPATH(), "GOBIN=" + GOBIN, } @@ -200,11 +201,24 @@ func doTest(cmdline []string) { coverage = flag.Bool("coverage", false, "Whether to record code coverage") ) flag.CommandLine.Parse(cmdline) + packages := []string{"./..."} if len(flag.CommandLine.Args()) > 0 { packages = flag.CommandLine.Args() } - + if len(packages) == 1 && packages[0] == "./..." { + // Resolve ./... manually since go vet will fail on vendored stuff + out, err := goTool("list", "./...").CombinedOutput() + if err != nil { + log.Fatalf("package listing failed: %v\n%s", err, string(out)) + } + packages = []string{} + for _, line := range strings.Split(string(out), "\n") { + if !strings.Contains(line, "vendor") { + packages = append(packages, strings.TrimSpace(line)) + } + } + } // Run analysis tools before the tests. if *vet { build.MustRun(goTool("vet", packages...)) diff --git a/internal/build/util.go b/internal/build/util.go index be41efed75..2a4a975735 100644 --- a/internal/build/util.go +++ b/internal/build/util.go @@ -55,16 +55,7 @@ func GOPATH() string { if len(path) == 0 { log.Fatal("GOPATH is not set") } - // Ensure Godeps workspace is present in the path. - godeps, _ := filepath.Abs(filepath.Join("Godeps", "_workspace")) - for _, dir := range path { - if dir == godeps { - return strings.Join(path, string(filepath.ListSeparator)) - } - } - newpath := append(path[:1], godeps) - newpath = append(newpath, path[1:]...) - return strings.Join(newpath, string(filepath.ListSeparator)) + return strings.Join(path, string(filepath.ListSeparator)) } // VERSION returns the content of the VERSION file.