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:
		| @@ -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 | ||||
|   | ||||
| @@ -21,7 +21,7 @@ set -o pipefail | ||||
| KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. | ||||
| source "${KUBE_ROOT}/hack/lib/init.sh" | ||||
|  | ||||
| kube::golang::old::setup_env | ||||
| kube::golang::new::setup_env | ||||
| kube::golang::setup_gomaxprocs | ||||
|  | ||||
| # start the cache mutation detector by default so that cache mutators will be found | ||||
| @@ -42,7 +42,6 @@ kube::test::find_dirs() { | ||||
|           -o -path './_gopath/*' \ | ||||
|           -o -path './cmd/kubeadm/test/*' \ | ||||
|           -o -path './contrib/podex/*' \ | ||||
|           -o -path './output/*' \ | ||||
|           -o -path './release/*' \ | ||||
|           -o -path './target/*' \ | ||||
|           -o -path './test/e2e/e2e_test.go' \ | ||||
| @@ -53,7 +52,7 @@ kube::test::find_dirs() { | ||||
|           -o -path './staging/*' \ | ||||
|           -o -path './vendor/*' \ | ||||
|         \) -prune \ | ||||
|       \) -name '*_test.go' -print0 | xargs -0n1 dirname | sed "s|^\./|${KUBE_GO_PACKAGE}/|" | LC_ALL=C sort -u | ||||
|       \) -name '*_test.go' -print0 | xargs -0n1 dirname | LC_ALL=C sort -u | ||||
|  | ||||
|     find ./staging -name '*_test.go' -not -path '*/test/integration/*' -prune -print0 | xargs -0n1 dirname | sed 's|^\./staging/src/|./vendor/|' | LC_ALL=C sort -u | ||||
|   ) | ||||
| @@ -165,7 +164,7 @@ for arg; do | ||||
|   fi | ||||
| done | ||||
| if [[ ${#testcases[@]} -eq 0 ]]; then | ||||
|   while IFS='' read -r line; do testcases+=("$line"); done < <(kube::test::find_dirs) | ||||
|   kube::util::read-array testcases < <(kube::test::find_dirs) | ||||
| fi | ||||
| set -- "${testcases[@]+${testcases[@]}}" | ||||
|  | ||||
| @@ -219,7 +218,7 @@ runTests() { | ||||
|  | ||||
|   # Try to normalize input names. | ||||
|   local -a targets | ||||
|   while IFS="" read -r target; do targets+=("$target"); done < <(kube::golang::binaries_from_targets "$@") | ||||
|   kube::util::read-array targets < <(kube::golang::normalize_go_targets "$@") | ||||
|  | ||||
|   # If we're not collecting coverage, run all requested tests with one 'go test' | ||||
|   # command, which is much faster. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Tim Hockin
					Tim Hockin