improve test running script

This commit is contained in:
Noah Levitt 2015-11-18 01:59:32 +00:00
parent 4bb7e043d4
commit df31068c80

View File

@ -1,24 +1,29 @@
#!/bin/bash
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
docker build -t internetarchive/warcprox-tests $script_dir || exit 1
uid=$(id -u)
user=$(id -un)
#
# Runs tests in a docker container. Also runs a temporary instance of rethinkdb
# inside the container. The tests run with rethinkdb features enabled, against
# that instance of rethinkdb, and also run without rethinkdb features enabled.
# With python 2.7 and 3.4.
#
# 😬
#
set -e
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
docker build -t internetarchive/warcprox-tests $script_dir
for python in python2.7 python3.4
do
docker run --rm -i -t --volume="$script_dir/..:/warcprox" internetarchive/warcprox-tests /sbin/my_init -- \
bash -x -c " adduser --gecos=$user --disabled-password --quiet --uid=$uid $user \
&& sudo PYTHONDONTWRITEBYTECODE=1 -u $user bash -x -c 'cd /warcprox \
&& virtualenv -p $python /tmp/venv \
&& source /tmp/venv/bin/activate \
&& pip --log-file /tmp/pip.log install . pytest requests \
&& py.test -s tests \
&& py.test -s --rethinkdb-servers=localhost tests \
&& py.test -s --rethinkdb-servers=localhost --rethinkdb-big-table tests'"
docker run --rm --volume="$script_dir/..:/warcprox" internetarchive/warcprox-tests /sbin/my_init -- \
bash -x -c "cd /tmp && git clone /warcprox && cd /tmp/warcprox \
&& (cd /warcprox && git diff) | patch -p1 \
&& virtualenv -p $python /tmp/venv \
&& source /tmp/venv/bin/activate \
&& pip --log-file /tmp/pip.log install . pytest requests \
&& py.test -s tests \
&& py.test -s --rethinkdb-servers=localhost tests \
&& py.test -s --rethinkdb-servers=localhost --rethinkdb-big-table tests"
done