Clean up test.sh and get rid of GOPATH

Result: `make test` works:

```
$ #### BUILD ####

$ make WHAT="./cmd/kubectl/ ./staging/src/k8s.io/api"
+++ [1211 11:20:46] Building go targets for linux/amd64
    ./cmd/kubectl/ (non-static)
    ./staging/src/k8s.io/api (non-static)

$ #### TEST ####

$ make test WHAT=./pkg/proxy/iptables/
+++ [1211 11:22:31] Set GOMAXPROCS automatically to 6
+++ [1211 11:22:31] Running tests without code coverage and with -race
ok  	k8s.io/kubernetes/pkg/proxy/iptables	9.517s

$ make test WHAT=pkg/proxy/iptables/
+++ [1211 11:22:53] Set GOMAXPROCS automatically to 6
+++ [1211 11:22:53] Running tests without code coverage and with -race
ok  	k8s.io/kubernetes/pkg/proxy/iptables	(cached)

$ make test WHAT=k8s.io/kubernetes/pkg/proxy/iptables/
+++ [1211 11:23:09] Set GOMAXPROCS automatically to 6
+++ [1211 11:23:09] Running tests without code coverage and with -race
ok  	k8s.io/kubernetes/pkg/proxy/iptables	(cached)

$ make test WHAT=./staging/src/k8s.io/api
+++ [1211 11:23:24] Set GOMAXPROCS automatically to 6
+++ [1211 11:23:24] Running tests without code coverage and with -race
ok  	k8s.io/api	21.981s

$ make test WHAT=staging/src/k8s.io/api
+++ [1211 11:23:54] Set GOMAXPROCS automatically to 6
+++ [1211 11:23:54] Running tests without code coverage and with -race
ok  	k8s.io/api	(cached)

$ make test WHAT=k8s.io/api
+++ [1211 11:24:06] Set GOMAXPROCS automatically to 6
+++ [1211 11:24:06] Running tests without code coverage and with -race
ok  	k8s.io/api	(cached)
```
This commit is contained in:
Tim Hockin
2022-01-10 09:06:43 -08:00
parent 8cb8535d9c
commit f3c8e92def
2 changed files with 13 additions and 14 deletions

View File

@@ -368,13 +368,11 @@ kube::golang::is_statically_linked_library() {
return 1;
}
# binaries_from_targets takes a list of build targets, which might be go
# targets (e.g. example.com/foo/bar or ./foo/bar) or local paths (e.g. foo/bar)
# and produces a respective list (on stdout) of our best guess at Go target
# names.
kube::golang::binaries_from_targets() {
# We can't just `go list -find` on each input because sometimes they are
# files (e.g. ".../pkg.test") which don't exist. Also it's very slow.
# kube::golang::normalize_go_targets takes a list of build targets, which might
# be Go-style names (e.g. example.com/foo/bar or ./foo/bar) or just local paths
# (e.g. foo/bar) and produces a respective list (on stdout) of our best guess at
# Go target names.
kube::golang::normalize_go_targets() {
local target
for target; do
if [ "${target}" = "ginkgo" ] ||
@@ -410,7 +408,9 @@ kube::golang::binaries_from_targets() {
# Otherwise assume it's a relative path (e.g. foo/bar or foo/bar/bar.test).
# We probably SHOULDN'T accept this, but we did in the past and it would be
# rude to break things if we don't NEED to.
# rude to break things if we don't NEED to. We can't really test if it
# exists or not, because the last element might be an output file (e.g.
# bar.test) or even "...".
echo "./${target}"
done
}
@@ -974,7 +974,7 @@ kube::golang::build_binaries() {
fi
local -a binaries
kube::util::read-array binaries < <(kube::golang::binaries_from_targets "${targets[@]}")
kube::util::read-array binaries < <(kube::golang::normalize_go_targets "${targets[@]}")
local parallel=false
if [[ ${#platforms[@]} -gt 1 ]]; then