all.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. set -o errexit
  3. set -o nounset
  4. set -o pipefail
  5. ROOT=$(dirname "${BASH_SOURCE}")/..
  6. # Some useful colors.
  7. if [[ -z "${color_start-}" ]]; then
  8. declare -r color_start="\033["
  9. declare -r color_red="${color_start}0;31m"
  10. declare -r color_yellow="${color_start}0;33m"
  11. declare -r color_green="${color_start}0;32m"
  12. declare -r color_norm="${color_start}0m"
  13. fi
  14. SILENT=true
  15. function is-excluded {
  16. for e in $EXCLUDE; do
  17. if [[ $1 -ef ${BASH_SOURCE} ]]; then
  18. return
  19. fi
  20. if [[ $1 -ef "$ROOT/hack/$e" ]]; then
  21. return
  22. fi
  23. done
  24. return 1
  25. }
  26. while getopts ":v" opt; do
  27. case $opt in
  28. v)
  29. SILENT=false
  30. ;;
  31. \?)
  32. echo "Invalid flag: -$OPTARG" >&2
  33. exit 1
  34. ;;
  35. esac
  36. done
  37. if $SILENT ; then
  38. echo "Running in the silent mode, run with -v if you want to see script logs."
  39. fi
  40. EXCLUDE="all.sh"
  41. ret=0
  42. for t in `ls $ROOT/verify/*.sh`
  43. do
  44. if is-excluded $t ; then
  45. echo "Skipping $t"
  46. continue
  47. fi
  48. if $SILENT ; then
  49. echo -e "Verifying $t"
  50. if bash "$t" &> /dev/null; then
  51. echo -e "${color_green}SUCCESS${color_norm}"
  52. else
  53. echo -e "${color_red}FAILED${color_norm}"
  54. ret=1
  55. fi
  56. else
  57. bash "$t" || ret=1
  58. fi
  59. done
  60. exit $ret