1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-12-11 21:14:34 +00:00
MarlinFirmware/buildroot/share/tests/run_tests

42 lines
1.0 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
2018-10-09 04:03:53 +00:00
#
# run_tests
#
export PATH="$PATH:$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )"
export PATH="$PATH:./buildroot/bin"
# exit on first failure
set -e
exec_test () {
2018-10-02 09:25:46 +00:00
printf "\n\033[0;32m[Test $2] \033[0m$3...\n"
2020-01-17 09:11:24 +00:00
if platformio run --project-dir $1 -e $2 --silent; then
printf "\033[0;32mPassed\033[0m\n"
return 0
else
2020-01-17 08:39:22 +00:00
git reset --hard HEAD
printf "\033[0;31mFailed!\033[0m\n"
return 1
fi
}
export -f exec_test
printf "Running \033[0;32m$2\033[0m Tests\n"
if [[ $2 = "ALL" ]]; then
dir_list=("$(dirname "${BASH_SOURCE[0]}")"/*)
2018-10-09 04:03:53 +00:00
declare -a tests=(${dir_list[@]/*run_tests/})
for f in "${tests[@]}"; do
2019-02-23 01:09:10 +00:00
testenv=$(basename $f | cut -d"-" -f1)
printf "Running \033[0;32m$f\033[0m Tests\n"
exec_test $1 "$testenv --target clean" "Setup Build Environment"
$f $1 $testenv
2020-01-17 08:39:22 +00:00
git reset --hard HEAD
done
else
exec_test $1 "$2 --target clean" "Setup Build Environment"
2019-02-23 01:09:10 +00:00
$2-tests $1 $2
2020-01-17 08:39:22 +00:00
git reset --hard HEAD
fi
printf "\033[0;32mAll tests completed successfully\033[0m\n"