From f7fb21c39468554d27ccc53ad9aebabde744d18d Mon Sep 17 00:00:00 2001 From: Kenichi Omichi Date: Mon, 15 Jun 2020 18:03:12 +0000 Subject: [PATCH] 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. --- hack/verify-test-code.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hack/verify-test-code.sh b/hack/verify-test-code.sh index 2590eee9b8c..9e79b76360b 100755 --- a/hack/verify-test-code.sh +++ b/hack/verify-test-code.sh @@ -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.'