forked from robotpy/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
executable file
·90 lines (78 loc) · 1.59 KB
/
run_tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash -e
cd "$(dirname $0)"
BASE_TESTS="
arcade-drive
cscore-intermediate-vision
cscore-quick-vision
gearsbot
getting-started
gyro
iterative/src
mecanum-drive
motor-control
pacgoat
physics/src
physics-4wheel/src
physics-camsim/src
physics-mecanum/src
physics-spi/src
sample/src
tank-drive
timed/src
"
ROBOTPY_EXT_TESTS="
command-based
magicbot-simple
stateful-autonomous
"
NAVX_TESTS="
navx
navx-rotate-to-angle
navx-rotate-to-angle-arcade
"
IGNORED_TESTS="
physics-pathfinder
"
ALL_TESTS="${BASE_TESTS} ${ROBOTPY_EXT_TESTS} ${NAVX_TESTS}"
EVERY_TESTS="${ALL_TESTS} ${IGNORED_TESTS}"
if [ "$1" == "all" ]; then
TESTS="$ALL_TESTS"
elif [ "$1" == "base" ]; then
TESTS="$BASE_TESTS"
elif [ "$1" == "ext" ]; then
TESTS="$ROBOTPY_EXT_TESTS"
elif [ "$1" == "navx" ]; then
TESTS="$NAVX_TESTS"
else
echo "Usage: run_tests.sh all|base|ext|navx"
exit 1
fi
# Ensure that when new samples are added, they are added to the list of things
# to test. Otherwise, exit.
EVERY_TESTS=$(for i in ${EVERY_TESTS}; do
echo ./$i/robot.py
done | sort)
FOUND_TESTS=$(find . -name robot.py | sort)
if [ "$EVERY_TESTS" != "$FOUND_TESTS" ]; then
echo "Specified:"
echo "$EVERY_TESTS"
echo
echo "Found:"
echo "$FOUND_TESTS"
echo
if [ -z "$FORCE_ANYWAYS" ]; then
echo "ERROR: Not every robot.py file is in the list of tests!"
exit 1
fi
fi
for t in ${TESTS}; do
pushd $t > /dev/null
pwd
if ! python3 robot.py test --builtin "${@:2}"; then
EC=$?
echo "Test in $(pwd) failed"
exit 1
fi
popd > /dev/null
done
echo "All tests successful!"