mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 09:28:13 +00:00
Merge pull request #543 from MrMebelMan/run_tests_update
Update run_tests.sh: show totals, allow interrupts, add colors
This commit is contained in:
commit
ac318cc65b
@ -1,35 +1,41 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cd $(dirname $0)
|
declare -a results
|
||||||
MICROPYTHON=../build/unix/micropython
|
declare -i PYOPT=1 passed=0 failed=0 exit_code=0
|
||||||
PYOPT=1
|
declare COLOR_GREEN='\e[32m' COLOR_RED='\e[91m' COLOR_RESET='\e[39m'
|
||||||
|
declare MICROPYTHON=../build/unix/micropython
|
||||||
|
|
||||||
results=()
|
print_summary() {
|
||||||
error=0
|
|
||||||
|
|
||||||
if [ -z "$*" ]; then
|
|
||||||
list="test_*.py"
|
|
||||||
else
|
|
||||||
list="$*"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for i in $list; do
|
|
||||||
echo
|
echo
|
||||||
if $MICROPYTHON -O$PYOPT $i; then
|
echo 'Summary:'
|
||||||
results+=("OK $i")
|
echo '-------------------'
|
||||||
|
printf '%b\n' "${results[@]}"
|
||||||
|
if [ $exit_code == 0 ]; then
|
||||||
|
echo -e "${COLOR_GREEN}PASSED:${COLOR_RESET} $passed/$num_of_tests tests OK!"
|
||||||
else
|
else
|
||||||
results+=("FAIL $i")
|
echo -e "${COLOR_RED}FAILED:${COLOR_RESET} $failed/$num_of_tests tests failed!"
|
||||||
error=1
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
trap 'print_summary; echo -e "${COLOR_RED}Interrupted by user!${COLOR_RESET}"; exit 1' SIGINT
|
||||||
|
|
||||||
|
cd $(dirname $0)
|
||||||
|
|
||||||
|
[ -z "$*" ] && tests=(test_*.py) || tests=($*)
|
||||||
|
|
||||||
|
declare -i num_of_tests=${#tests[@]}
|
||||||
|
|
||||||
|
for test_case in ${tests[@]}; do
|
||||||
|
echo
|
||||||
|
if $MICROPYTHON -O$PYOPT $test_case; then
|
||||||
|
results+=("${COLOR_GREEN}OK:${COLOR_RESET} $test_case")
|
||||||
|
((passed++))
|
||||||
|
else
|
||||||
|
results+=("${COLOR_RED}FAIL:${COLOR_RESET} $test_case")
|
||||||
|
((failed++))
|
||||||
|
exit_code=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo
|
print_summary
|
||||||
echo 'Summary:'
|
exit $exit_code
|
||||||
printf '%s\n' "${results[@]}"
|
|
||||||
echo '-------------------'
|
|
||||||
if [ $error == 0 ]; then
|
|
||||||
echo 'ALL OK'
|
|
||||||
else
|
|
||||||
echo 'FAIL at least one error occurred'
|
|
||||||
fi
|
|
||||||
exit $error
|
|
||||||
|
Loading…
Reference in New Issue
Block a user