You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.0 KiB
Plaintext
42 lines
1.0 KiB
Plaintext
6 years ago
|
#!/usr/bin/env bash
|
||
6 years ago
|
#
|
||
|
# run_tests
|
||
|
#
|
||
6 years ago
|
export PATH="$PATH:$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )"
|
||
|
export PATH="$PATH:./buildroot/bin"
|
||
|
|
||
|
# exit on first failure
|
||
|
set -e
|
||
|
|
||
6 years ago
|
exec_test () {
|
||
6 years ago
|
printf "\n\033[0;32m[Test $2] \033[0m$3...\n"
|
||
5 years ago
|
if platformio run --project-dir $1 -e $2 --silent; then
|
||
6 years ago
|
printf "\033[0;32mPassed\033[0m\n"
|
||
|
return 0
|
||
|
else
|
||
5 years ago
|
git reset --hard HEAD
|
||
6 years ago
|
printf "\033[0;31mFailed!\033[0m\n"
|
||
|
return 1
|
||
|
fi
|
||
|
}
|
||
|
export -f exec_test
|
||
|
|
||
6 years ago
|
printf "Running \033[0;32m$2\033[0m Tests\n"
|
||
|
|
||
6 years ago
|
if [[ $2 = "ALL" ]]; then
|
||
6 years ago
|
dir_list=("$(dirname "${BASH_SOURCE[0]}")"/*)
|
||
6 years ago
|
declare -a tests=(${dir_list[@]/*run_tests/})
|
||
6 years ago
|
for f in "${tests[@]}"; do
|
||
6 years ago
|
testenv=$(basename $f | cut -d"-" -f1)
|
||
6 years ago
|
printf "Running \033[0;32m$f\033[0m Tests\n"
|
||
|
exec_test $1 "$testenv --target clean" "Setup Build Environment"
|
||
|
$f $1 $testenv
|
||
5 years ago
|
git reset --hard HEAD
|
||
6 years ago
|
done
|
||
|
else
|
||
|
exec_test $1 "$2 --target clean" "Setup Build Environment"
|
||
6 years ago
|
$2-tests $1 $2
|
||
5 years ago
|
git reset --hard HEAD
|
||
6 years ago
|
fi
|
||
|
printf "\033[0;32mAll tests completed successfully\033[0m\n"
|