A framework for Audit/Repair scripts for OpenStack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

run_tests.sh 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. function usage {
  3. echo "Usage: $0 [OPTION]..."
  4. echo "Run Entropy's test suite(s)"
  5. echo ""
  6. echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
  7. echo " -p, --pep8 Just run pep8"
  8. echo " -P, --no-pep8 Don't run static code checks"
  9. echo " -v, --verbose Increase verbosity of reporting output"
  10. echo " -h, --help Print this usage message"
  11. echo ""
  12. exit
  13. }
  14. function process_option {
  15. case "$1" in
  16. -h|--help) usage;;
  17. -p|--pep8) let just_pep8=1;;
  18. -P|--no-pep8) let no_pep8=1;;
  19. -f|--force) let force=1;;
  20. -v|--verbose) let verbose=1;;
  21. *) pos_args="$pos_args $1"
  22. esac
  23. }
  24. verbose=0
  25. force=0
  26. pos_args=""
  27. just_pep8=0
  28. no_pep8=0
  29. tox_args=""
  30. tox=""
  31. for arg in "$@"; do
  32. process_option $arg
  33. done
  34. py=`which python`
  35. if [ -z "$py" ]; then
  36. echo "Python is required to use $0"
  37. echo "Please install it via your distributions package management system."
  38. exit 1
  39. fi
  40. py_envs=`python -c 'import sys; print("py%s%s" % (sys.version_info[0:2]))'`
  41. py_envs=${PY_ENVS:-$py_envs}
  42. function run_tests {
  43. local tox_cmd="${tox} ${tox_args} -e $py_envs ${pos_args}"
  44. echo "Running tests for environments $py_envs via $tox_cmd"
  45. bash -c "$tox_cmd"
  46. }
  47. function run_flake8 {
  48. local tox_cmd="${tox} ${tox_args} -e pep8 ${pos_args}"
  49. echo "Running flake8 via $tox_cmd"
  50. bash -c "$tox_cmd"
  51. }
  52. if [ $force -eq 1 ]; then
  53. tox_args="$tox_args -r"
  54. fi
  55. if [ $verbose -eq 1 ]; then
  56. tox_args="$tox_args -v"
  57. fi
  58. tox=`which tox`
  59. if [ -z "$tox" ]; then
  60. echo "Tox is required to use $0"
  61. echo "Please install it via \`pip\` or via your distributions" \
  62. "package management system."
  63. echo "Visit http://tox.readthedocs.org/ for additional installation" \
  64. "instructions."
  65. exit 1
  66. fi
  67. if [ $just_pep8 -eq 1 ]; then
  68. run_flake8
  69. exit
  70. fi
  71. run_tests || exit
  72. if [ $no_pep8 -eq 0 ]; then
  73. run_flake8
  74. fi