Only normalize user-provided test targets

This commit is contained in:
Tim Hockin 2024-09-19 10:44:50 -07:00
parent 211d67a511
commit 7d89e9b4c0
No known key found for this signature in database

View File

@ -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=$?