2016-09-24 11:11:06 +00:00
|
|
|
#!/bin/bash
|
2017-04-25 14:18:44 +00:00
|
|
|
|
2019-04-08 22:58:14 +00:00
|
|
|
declare -a results
|
|
|
|
declare -i PYOPT=1 passed=0 failed=0 exit_code=0
|
|
|
|
declare COLOR_GREEN='\e[32m' COLOR_RED='\e[91m' COLOR_RESET='\e[39m'
|
2019-05-26 20:20:14 +00:00
|
|
|
declare MICROPYTHON=../build/unix/micropython
|
2019-04-08 22:58:14 +00:00
|
|
|
|
|
|
|
print_summary() {
|
|
|
|
echo
|
|
|
|
echo 'Summary:'
|
|
|
|
echo '-------------------'
|
|
|
|
printf '%b\n' "${results[@]}"
|
|
|
|
if [ $exit_code == 0 ]; then
|
|
|
|
echo -e "${COLOR_GREEN}PASSED:${COLOR_RESET} $passed/$num_of_tests tests OK!"
|
|
|
|
else
|
|
|
|
echo -e "${COLOR_RED}FAILED:${COLOR_RESET} $failed/$num_of_tests tests failed!"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
trap 'print_summary; echo -e "${COLOR_RED}Interrupted by user!${COLOR_RESET}"; exit 1' SIGINT
|
|
|
|
|
2019-03-26 13:12:09 +00:00
|
|
|
cd $(dirname $0)
|
2017-04-25 14:18:44 +00:00
|
|
|
|
2019-04-08 22:58:14 +00:00
|
|
|
[ -z "$*" ] && tests=(test_*.py) || tests=($*)
|
2017-04-25 14:18:44 +00:00
|
|
|
|
2019-04-08 22:58:14 +00:00
|
|
|
declare -i num_of_tests=${#tests[@]}
|
2017-04-25 14:18:44 +00:00
|
|
|
|
2019-04-08 22:58:14 +00:00
|
|
|
for test_case in ${tests[@]}; do
|
2017-04-25 14:18:44 +00:00
|
|
|
echo
|
2019-04-08 22:58:14 +00:00
|
|
|
if $MICROPYTHON -O$PYOPT $test_case; then
|
|
|
|
results+=("${COLOR_GREEN}OK:${COLOR_RESET} $test_case")
|
|
|
|
((passed++))
|
2016-09-24 11:11:06 +00:00
|
|
|
else
|
2019-04-08 22:58:14 +00:00
|
|
|
results+=("${COLOR_RED}FAIL:${COLOR_RESET} $test_case")
|
|
|
|
((failed++))
|
|
|
|
exit_code=1
|
2016-09-24 11:11:06 +00:00
|
|
|
fi
|
2016-04-12 16:09:23 +00:00
|
|
|
done
|
2017-04-25 14:18:44 +00:00
|
|
|
|
2019-04-08 22:58:14 +00:00
|
|
|
print_summary
|
|
|
|
exit $exit_code
|