2018-07-14 06:42:15 +02:00
|
|
|
#!/usr/bin/env bash
|
2018-09-01 09:50:47 +02:00
|
|
|
#
|
|
|
|
# start_tests
|
|
|
|
#
|
|
|
|
# Run one or more tests
|
|
|
|
#
|
|
|
|
|
2018-07-14 06:42:15 +02:00
|
|
|
export PATH="$PATH:$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )"
|
|
|
|
export PATH="$PATH:./buildroot/bin"
|
|
|
|
|
|
|
|
# exit on first failure
|
|
|
|
set -e
|
|
|
|
|
2018-09-01 09:50:47 +02:00
|
|
|
exec_test() {
|
2018-07-14 06:42:15 +02:00
|
|
|
printf "\033[0;32m[Test $2] \033[0m$3... "
|
|
|
|
if build_marlin_pio $1 "-e $2"; then
|
|
|
|
printf "\033[0;32mPassed\033[0m\n"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
env_restore
|
|
|
|
printf "\033[0;31mFailed!\033[0m\n"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
export -f exec_test
|
|
|
|
|
2018-08-25 01:53:24 +02:00
|
|
|
if [[ $3 = "--deep-clean" ]]; then
|
|
|
|
echo "Deleting all PlatformIO caches, downloads and installed packages..."
|
|
|
|
env_clean --deep
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $2 = "ALL" ]]; then
|
2018-07-14 06:42:15 +02:00
|
|
|
dir_list=("$(dirname "${BASH_SOURCE[0]}")"/*)
|
|
|
|
declare -a tests=(${dir_list[@]/*start_tests/})
|
|
|
|
for f in "${tests[@]}"; do
|
|
|
|
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
|
|
|
|
done
|
|
|
|
else
|
2018-09-01 09:50:47 +02:00
|
|
|
printf "Running \033[0;32m$2\033[0m Tests\n"
|
2018-07-14 06:42:15 +02:00
|
|
|
exec_test $1 "$2 --target clean" "Setup Build Environment"
|
|
|
|
$2_tests $1 $2
|
|
|
|
fi
|
2018-09-01 09:50:47 +02:00
|
|
|
|
2018-07-14 06:42:15 +02:00
|
|
|
printf "\033[0;32mAll tests completed successfully\033[0m\n"
|