diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index 03cea62bc0d..fc8fc402fee 100755 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -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 diff --git a/hack/make-rules/test.sh b/hack/make-rules/test.sh index 6874d9d397a..400e630d448 100755 --- a/hack/make-rules/test.sh +++ b/hack/make-rules/test.sh @@ -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.