Handle AllAlpha and AllBeta in SetFeatureGateDuringTest

This commit is contained in:
Jordan Liggitt
2023-02-28 16:59:19 -05:00
parent 3835c7aecd
commit d0a213aba2
3 changed files with 145 additions and 2 deletions

View File

@@ -30,7 +30,7 @@ cd "${KUBE_ROOT}"
rc=0
# find test files accessing the mutable global feature gate or interface
direct_sets=$(find -L . -name '*_test.go' -exec grep -Hn 'MutableFeatureGate' {} \; 2>/dev/null) || true
direct_sets=$(git grep MutableFeatureGate -- '*_test.go') || true
if [[ -n "${direct_sets}" ]]; then
echo "Test files may not access mutable global feature gates directly:" >&2
echo "${direct_sets}" >&2
@@ -42,7 +42,7 @@ if [[ -n "${direct_sets}" ]]; then
fi
# find test files calling SetFeatureGateDuringTest and not calling the result
missing_defers=$(find -L . -name '*_test.go' -exec grep -Hn 'SetFeatureGateDuringTest' {} \; 2>/dev/null | grep -E -v "defer .*\\)\\(\\)$") || true
missing_defers=$(git grep "\\.SetFeatureGateDuringTest" -- '*_test.go' | grep -E -v "defer .*\\)\\(\\)$") || true
if [[ -n "${missing_defers}" ]]; then
echo "Invalid invocations of featuregatetesting.SetFeatureGateDuringTest():" >&2
echo "${missing_defers}" >&2