aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-03-23 22:46:03 +0800
committerFelix Lange <fjl@twurst.com>2017-03-23 22:50:05 +0800
commite7911ad9ea38eaf8707b7247a5ac96bc81de856c (patch)
tree91f58f53f8bcfa45f8141ca2b0bc721b0a9ca656
parent11e7a712f469fb24ddb88ecebcefab6ed8880eb8 (diff)
downloadgo-tangerine-e7911ad9ea38eaf8707b7247a5ac96bc81de856c.tar
go-tangerine-e7911ad9ea38eaf8707b7247a5ac96bc81de856c.tar.gz
go-tangerine-e7911ad9ea38eaf8707b7247a5ac96bc81de856c.tar.bz2
go-tangerine-e7911ad9ea38eaf8707b7247a5ac96bc81de856c.tar.lz
go-tangerine-e7911ad9ea38eaf8707b7247a5ac96bc81de856c.tar.xz
go-tangerine-e7911ad9ea38eaf8707b7247a5ac96bc81de856c.tar.zst
go-tangerine-e7911ad9ea38eaf8707b7247a5ac96bc81de856c.zip
build: unify vendor skipping logic
This fixes a recent bug where 'make geth' built everything instead of just geth.
-rw-r--r--build/ci.go29
-rw-r--r--internal/build/util.go28
2 files changed, 31 insertions, 26 deletions
diff --git a/build/ci.go b/build/ci.go
index 27589fc7f..fcdd33788 100644
--- a/build/ci.go
+++ b/build/ci.go
@@ -173,19 +173,7 @@ func doInstall(cmdline []string) {
if flag.NArg() > 0 {
packages = flag.Args()
}
-
- // Resolve ./... manually and remove vendor/bazil/fuse (fuse is not in windows)
- 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))
- }
- }
-
+ packages = build.ExpandPackagesNoVendor(packages)
if *arch == "" || *arch == runtime.GOARCH {
goinstall := goTool("install", buildFlags(env)...)
@@ -284,19 +272,8 @@ func doTest(cmdline []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))
- }
- }
- }
+ packages = build.ExpandPackagesNoVendor(packages)
+
// 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 4df7b9138..44f6760b9 100644
--- a/internal/build/util.go
+++ b/internal/build/util.go
@@ -26,6 +26,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "runtime"
"strings"
"text/template"
)
@@ -136,3 +137,30 @@ func CopyFile(dst, src string, mode os.FileMode) {
log.Fatal(err)
}
}
+
+// ExpandPackagesNoVendor expands a cmd/go import path pattern, skipping
+// vendored packages.
+func ExpandPackagesNoVendor(patterns []string) []string {
+ expand := false
+ for _, pkg := range patterns {
+ if strings.Contains(pkg, "...") {
+ expand = true
+ }
+ }
+ if expand {
+ args := append([]string{"list"}, patterns...)
+ cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), args...)
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ log.Fatalf("package listing failed: %v\n%s", err, string(out))
+ }
+ var packages []string
+ for _, line := range strings.Split(string(out), "\n") {
+ if !strings.Contains(line, "/vendor/") {
+ packages = append(packages, strings.TrimSpace(line))
+ }
+ }
+ return packages
+ }
+ return patterns
+}