forked from yourlabs/django-autocomplete-light
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·67 lines (50 loc) · 2.09 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Enable tracing (display executed lines)
set -x
# Halt on error!
set -e
WORKSPACE="${WORKSPACE:-$(pwd)}"
CLEAN_VIRTUALENV="${CLEAN_VIRTUALENV:-0}"
DJANGO_TAGGIT="${DJANGO_TAGGIT:-1}"
DJANGO_GENERIC_M2M="${DJANGO_GENERIC_M2M:-1}"
PYTHON_VERSION="${PYTHON_VERSION:-3.3}"
DJANGO_VERSION="${DJANGO_VERSION:-1.5}"
POSTGRES_USER="${POSTGRES_USER:-postgres}"
# for debug, it could be -e /dev/stdout
XVFB_FLAGS="${XVFB_FLAGS:-}"
export DATABASE_NAME="autocomplete_light_test_${BUILD_ID}${PYTHON_VERSION}${DJANGO_VERSION}${DJANGO_TAGGIT}${DJANGO_GENERIC_M2M}"
export DATABASE_NAME="${DATABASE_NAME//[._-]}"
function clean {
psql -c "drop database if exists $DATABASE_NAME;" -U $POSTGRES_USER
}
trap 'clean; exit' SIGINT SIGQUIT
# Make a unique env path for this configuration
ENV_PATH="$WORKSPACE/test_env"
psql -c "drop database if exists $DATABASE_NAME;" -U $POSTGRES_USER
psql -c "create database $DATABASE_NAME;" -U $POSTGRES_USER
# Get real django version
[ "$DJANGO_VERSION" = "1.4" ] && DJANGO_VERSION="1.4.10"
[ "$DJANGO_VERSION" = "1.5" ] && DJANGO_VERSION="1.5.5"
[ "$DJANGO_VERSION" = "1.6" ] && DJANGO_VERSION="1.6"
# Clean virtualenv if necessary
[ "$CLEAN_VIRTUALENV" = "1" ] && rm -rf $ENV_PATH
# Make virtualenv if necessary
[ ! -d "$ENV_PATH" ] && virtualenv-$PYTHON_VERSION $ENV_PATH
# Shebangs are too long without this and the kernel truncates them at 127
# characters.
virtualenv-$PYTHON_VERSION --relocatable $ENV_PATH
source $ENV_PATH/bin/activate
[ "$DJANGO_TAGGIT" = "1" ] && DJANGO_TAGGIT=django-taggit || DJANGO_TAGGIT=""
[ "$DJANGO_GENERIC_M2M" = "1" ] && DJANGO_GENERIC_M2M=django-generic-m2m || DJANGO_GENERIC_M2M=""
# 2.1.7 has a bad migration
pip install django-cities-light==2.1.8
pip install $DJANGO_TAGGIT $DJANGO_GENERIC_M2M \
-e $WORKSPACE \
-r $WORKSPACE/test_project/requirements.txt \
-r $WORKSPACE/test_project/test_requirements.txt \
django==$DJANGO_VERSION
cd $WORKSPACE
xvfb-run -a $XVFB_FLAGS test_project/manage.py test autocomplete_light --noinput --liveserver=localhost:9000-9200 --settings=test_project.settings_postgres
RET="$?"
clean
exit $RET