runtests.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh
  2. # GNU MediaGoblin -- federated, autonomous media hosting
  3. # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU Affero General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU Affero General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. basedir="`dirname $0`"
  18. # Directory to seaerch for:
  19. subdir="mediagoblin/tests"
  20. [ '!' -d "$basedir/$subdir" ] && basedir="."
  21. if [ '!' -d "$basedir/$subdir" ]
  22. then
  23. echo "Could not find base directory" >&2
  24. exit 1
  25. fi
  26. if [ -x "$basedir/bin/py.test" ]; then
  27. export PYTEST="$basedir/bin/py.test";
  28. echo "Using $PYTEST";
  29. elif which py.test > /dev/null; then
  30. echo "Using py.test from \$PATH";
  31. export PYTEST="py.test";
  32. else
  33. echo "py.test not found. X_X";
  34. echo "Please install pytest e.g. with 'pip install pytest'. Exiting.";
  35. exit 1
  36. fi
  37. # Look to see if the user has specified a specific directory/file to
  38. # run tests out of. If not we'll need to pass along
  39. # mediagoblin/tests/ later very specifically. Otherwise py.test
  40. # will try to read all directories, and this turns into a mess!
  41. need_arg=1
  42. ignore_next=0
  43. for i in "$@"
  44. do
  45. if [ "$ignore_next" = 1 ]
  46. then
  47. ignore_next=0
  48. continue
  49. fi
  50. case "$i" in
  51. -n) ignore_next=1;;
  52. -*) ;;
  53. *) need_arg=0; break ;;
  54. esac
  55. done
  56. if [ "$need_arg" = 1 ]
  57. then
  58. testdir="$basedir/mediagoblin/tests"
  59. set -x
  60. exec "$PYTEST" "$@" "$testdir" --boxed
  61. else
  62. set -x
  63. exec "$PYTEST" "$@" --boxed
  64. fi