My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

run_tests 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/env bash
  2. #
  3. # run_tests
  4. #
  5. export PATH="$PATH:$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )"
  6. export PATH="$PATH:./buildroot/bin"
  7. # exit on first failure
  8. set -e
  9. exec_test () {
  10. printf "\n\033[0;32m[Test $2] \033[0m$3...\n"
  11. # Check to see if we should skip tests
  12. if [[ -n "$4" ]] ; then
  13. if [[ ! "$3" =~ $4 ]] ; then
  14. printf "\033[1;33mSkipped\033[0m\n"
  15. return 0
  16. fi
  17. fi
  18. if [[ -z "$VERBOSE_PLATFORMIO" ]] ; then
  19. silent="--silent"
  20. else
  21. silent=""
  22. fi
  23. if platformio run --project-dir $1 -e $2 $silent; then
  24. printf "\033[0;32mPassed\033[0m\n"
  25. return 0
  26. else
  27. if [[ -n $GIT_RESET_HARD ]]; then
  28. git reset --hard HEAD
  29. else
  30. restore_configs
  31. fi
  32. printf "\033[0;31mFailed!\033[0m\n"
  33. return 1
  34. fi
  35. }
  36. export -f exec_test
  37. printf "Running \033[0;32m$2\033[0m Tests\n"
  38. if [[ $2 = "ALL" ]]; then
  39. dir_list=("$(dirname "${BASH_SOURCE[0]}")"/*)
  40. declare -a tests=(${dir_list[@]/*run_tests/})
  41. for f in "${tests[@]}"; do
  42. testenv=$(basename $f | cut -d"-" -f1)
  43. printf "Running \033[0;32m$f\033[0m Tests\n"
  44. exec_test $1 "$testenv --target clean" "Setup Build Environment"
  45. if [[ $GIT_RESET_HARD == "true" ]]; then
  46. git reset --hard HEAD
  47. else
  48. restore_configs
  49. fi
  50. done
  51. else
  52. exec_test $1 "$2 --target clean" "Setup Build Environment"
  53. test_name="$3"
  54. # If the test name is 1 or 2 digits, treat it as an index
  55. if [[ "$test_name" =~ ^[0-9][0-9]?$ ]] ; then
  56. # Find the test name that corresponds to that index
  57. test_name="$(cat buildroot/tests/$2-tests | grep -e '^exec_test' | sed -n "$3p" | sed "s/.*\$1 \$2 \"\([^\"]*\).*/\1/g")"
  58. if [[ -z "$test_name" ]] ; then
  59. # Fail if none matches
  60. printf "\033[0;31mCould not find test \033[0m#$3\033[0;31m in \033[0mbuildroot/tests/$2-tests\n"
  61. exit 1
  62. else
  63. printf "\033[0;32mMatching test \033[0m#$3\033[0;32m: '\033[0m$test_name\033[0;32m'\n"
  64. fi
  65. fi
  66. $2-tests $1 $2 "$test_name"
  67. if [[ $GIT_RESET_HARD == "true" ]]; then
  68. git reset --hard HEAD
  69. else
  70. restore_configs
  71. fi
  72. fi
  73. printf "\033[0;32mAll tests completed successfully\033[0m\n"