Skip to content

Commit 24dbf03

Browse files
committed
Added check for naive funcs at head of test file
1 parent 8ac6a8c commit 24dbf03

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ check_print()
5858
fi
5959
}
6060

61+
check_naive()
62+
{
63+
# Check if there are any naive implementations not at start of test file
64+
for testfile in tests/test_*.py
65+
do
66+
last_naive="$(grep -n 'def naive_' $testfile | tail -n 1 | awk -F: '{print $1}')"
67+
first_test="$(grep -n 'def test_' $testfile | head -n 1 | awk -F: '{print $1}')"
68+
if [[ ! -z $last_naive && ! -z $first_test && $last_naive -gt $first_test ]]; then
69+
echo "Error: naive implementation found in the middle of $testfile line $last_naive"
70+
exit 1
71+
fi
72+
done
73+
}
74+
6175
test_custom()
6276
{
6377
# export NUMBA_DISABLE_JIT=1
@@ -150,6 +164,7 @@ clean_up
150164
check_black
151165
check_flake
152166
check_print
167+
check_naive
153168

154169
if [[ $test_mode == "unit" ]]; then
155170
echo "Executing Unit Tests Only"

0 commit comments

Comments
 (0)