diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index ae48527885c..76c76092dc0 100755 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -830,7 +830,7 @@ kube::golang::build_binaries_for_platform() { for binary in "${binaries[@]}"; do if [[ "${binary}" =~ ".test"$ ]]; then tests+=("${binary}") - kube::log::info " ${binary} (test)" + kube::log::info " ${binary} (test${KUBE_RACE:+, race detection})" elif kube::golang::is_statically_linked "${binary}"; then statics+=("${binary}") kube::log::info " ${binary} (static)" @@ -863,7 +863,7 @@ kube::golang::build_binaries_for_platform() { -tags="${gotags:-}" ) if [[ -n "${KUBE_RACE:-}" ]]; then - build_args+=("${KUBE_RACE}") + build_args+=("${KUBE_RACE}") fi kube::golang::build_some_binaries "${nonstatics[@]}" fi @@ -874,13 +874,18 @@ kube::golang::build_binaries_for_platform() { testpkg=$(dirname "${test}") mkdir -p "$(dirname "${outfile}")" - go test -c \ - ${goflags:+"${goflags[@]}"} \ - -gcflags="${gogcflags}" \ - -ldflags="${goldflags}" \ - -tags="${gotags:-}" \ - -o "${outfile}" \ - "${testpkg}" + build_args=( + -c + ${goflags:+"${goflags[@]}"} + -gcflags="${gogcflags}" + -ldflags="${goldflags}" + -tags="${gotags:-}" + -o "${outfile}" + ) + if [[ -n "${KUBE_RACE:-}" ]]; then + build_args+=("${KUBE_RACE}") + fi + go test "${build_args[@]}" "${testpkg}" done }