Add check for blocking tests in e2e framework

e2e test framework provides useful functions for implementing e2e tests,
but the framework itself should not contain e2e tests theirself.
This adds hacking check for blocking implementing e2e tests in the
framework.
This commit is contained in:
Kenichi Omichi 2020-06-15 18:03:12 +00:00
parent 98f250f883
commit f7fb21c394

View File

@ -64,6 +64,17 @@ do
fi
done
all_e2e_framework_files=()
kube::util::read-array all_e2e_framework_files < <(find test/e2e/framework/ -name '*.go' | grep -v "_test.go")
errors_framework_contains_tests=()
for file in "${all_e2e_framework_files[@]}"
do
if grep -E "(ConformanceIt\(.*, func\(\) {|ginkgo.It\(.*, func\(\) {)" "${file}" > /dev/null
then
errors_framework_contains_tests+=( "${file}" )
fi
done
if [ ${#errors_expect_no_error[@]} -ne 0 ]; then
{
echo "Errors:"
@ -120,4 +131,18 @@ if [ ${#errors_expect_equal[@]} -ne 0 ]; then
exit 1
fi
if [ ${#errors_framework_contains_tests[@]} -ne 0 ]; then
{
echo "Errors:"
for err in "${errors_framework_contains_tests[@]}"; do
echo "$err"
done
echo
echo 'The above e2e framework files should not contain any e2e tests which are implemented '
echo 'with framework.ConformanceIt() or ginkgo.It()'
echo
} >&2
exit 1
fi
echo 'Congratulations! All e2e test source files are valid.'