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