Fixed some of the test typos/behaviors.
[mediagoblin-automation:mediagoblin-selenium.git] / scripts / runtests.sh
1 #!/bin/bash
2
3 # GNU MediaGoblin Selenium Automation
4 # Copyright (C) 2013 Emily O'Leary
5 #
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.
10 #
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.
15 #
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/>.
18
19 basedir=${PWD}
20 #Note: This will change once made into a parameter.
21 data="data.ini"
22 cd mediagoblin
23 tflag=0
24 while getopts tests: name
25 do
26     case $name in
27     branch) tflag=1
28             testdir="$OPTARG";;
29     ?)      echo "Usage: $0: [-tests value]"
30             exit 2;;
31     esac
32 done
33
34 if [ -x "$basedir/mediagoblin/bin/py.test" ]; then
35     export PYTEST="$basedir/mediagoblin/bin/py.test";
36     echo "Using $PYTEST";
37 elif which py.test > /dev/null; then
38     echo "Using py.test from \$PATH";
39     export PYTEST="py.test";
40 else
41     echo "py.test not found.  X_X";
42     echo "Please install 'py.test'.  Exiting.";
43     exit 1
44 fi
45
46 $basedir/mediagoblin/lazyserver.sh&
47
48 sleep 5s
49
50 if [ $tflag -ne 1 ]
51 then
52   testdir="$basedir/tests"
53 fi
54
55 rm -f $basedir/run/*.py
56 rm -f $basedir/run/util/*.py
57
58 for f in $testdir/*.py
59 do
60     m4 -DWORKING_DIRECTORY="$basedir" $f > $basedir/run/$(basename "$f")
61 done
62 for f in $testdir/util/*.py
63 do
64     m4 -DWORKING_DIRECTORY="$basedir" $f > $basedir/run/util/$(basename "$f")
65 done
66
67 source $basedir/mediagoblin/bin/activate
68 set -x
69 $basedir/scripts/setupTests.py --working=$basedir --data=$data
70 echo "Setup complete"
71 exec "$PYTEST" "$basedir/run" --boxed