Skip to content

Commit d2eecfe

Browse files
authored
Merge pull request kubernetes#80785 from oomichi/add-expectequal-hack
Add code check for framework.ExpectEqual()
2 parents e2e5a9e + ad98808 commit d2eecfe

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

hack/verify-test-code.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ do
4242
fi
4343
done
4444

45+
errors_expect_equal=()
46+
for file in "${all_e2e_files[@]}"
47+
do
48+
if grep -E "Expect\(.*\)\.To\((gomega\.Equal|Equal)" "${file}" > /dev/null
49+
then
50+
errors_expect_equal+=( "${file}" )
51+
fi
52+
done
53+
4554
if [ ${#errors_expect_no_error[@]} -ne 0 ]; then
4655
{
4756
echo "Errors:"
@@ -70,4 +79,18 @@ if [ ${#errors_expect_error[@]} -ne 0 ]; then
7079
exit 1
7180
fi
7281

82+
if [ ${#errors_expect_equal[@]} -ne 0 ]; then
83+
{
84+
echo "Errors:"
85+
for err in "${errors_expect_equal[@]}"; do
86+
echo "$err"
87+
done
88+
echo
89+
echo 'The above files need to use framework.ExpectEqual(foo, bar) instead of '
90+
echo 'Expect(foo).To(Equal(bar)) or gomega.Expect(foo).To(gomega.Equal(bar))'
91+
echo
92+
} >&2
93+
exit 1
94+
fi
95+
7396
echo 'Congratulations! All e2e test source files are valid.'

0 commit comments

Comments
 (0)