Cleanup defer from SetFeatureGateDuringTest function call

This commit is contained in:
Marek Siarkowicz
2024-04-23 10:39:47 +02:00
committed by Marek Siarkowicz
parent bf6507070c
commit 3ee8178768
187 changed files with 547 additions and 565 deletions

View File

@@ -36,19 +36,7 @@ if [[ -n "${direct_sets}" ]]; then
echo "${direct_sets}" >&2
echo >&2
echo "Use this invocation instead:" >&2
echo " defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.<FeatureName>, <value>)()" >&2
echo >&2
rc=1
fi
# find test files calling SetFeatureGateDuringTest and not calling the result
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
echo >&2
echo "Always make a deferred call to the returned function to ensure the feature gate is reset:" >&2
echo " defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.<FeatureName>, <value>)()" >&2
echo " featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.<FeatureName>, <value>)" >&2
echo >&2
rc=1
fi