diff --git a/hack/make-rules/test.sh b/hack/make-rules/test.sh index aa1617ea2e6..266aaa5db9a 100755 --- a/hack/make-rules/test.sh +++ b/hack/make-rules/test.sh @@ -147,6 +147,9 @@ goflags=() # Filter out arguments that start with "-" and move them to goflags. testcases=() +# if the user passed no target in, we can skip slow normalization. +normalize="true" + for arg; do if [[ "${arg}" == -* ]]; then goflags+=("${arg}") @@ -155,8 +158,15 @@ for arg; do fi done if [[ ${#testcases[@]} -eq 0 ]]; then + normalize="false" kube::util::read-array testcases < <(kube::test::find_dirs) fi + +if [[ "${normalize}" == "true" ]]; then + # This can be slow! + kube::log::status "Normalizing Go targets" + kube::util::read-array testcases < <(kube::golang::normalize_go_targets "${testcases[@]}") +fi set -- "${testcases[@]+${testcases[@]}}" if [[ -n "${KUBE_RACE}" ]] ; then @@ -190,11 +200,6 @@ runTests() { installTools - # Try to normalize input names. This is slow! - local -a targets - kube::log::status "Normalizing Go targets" - kube::util::read-array targets < <(kube::golang::normalize_go_targets "$@") - # Enable coverage data collection? local cover_msg local COMBINED_COVER_PROFILE @@ -229,7 +234,7 @@ runTests() { go test -json \ "${goflags[@]:+${goflags[@]}}" \ "${KUBE_TIMEOUT}" \ - "${targets[@]}" \ + "$@" \ "${testargs[@]:+${testargs[@]}}" \ && rc=$? || rc=$?