X Tutup
Skip to content

Commit c580b1e

Browse files
author
Gauvain Pocentek
committed
functional_tests.sh: support python 2 and 3
1 parent 81b0a06 commit c580b1e

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

tools/functional_tests.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ cleanup() {
2323
}
2424
trap cleanup EXIT
2525

26+
PY_VER=2
27+
while getopts :p: opt "$@"; do
28+
case $opt in
29+
p)
30+
PY_VER=$OPTARG;;
31+
*)
32+
echo "Unknown option: $opt"
33+
exit 1;;
34+
esac
35+
done
36+
37+
case $PY_VER in
38+
2) VENV_CMD=virtualenv;;
39+
3) VENV_CMD=pyvenv;;
40+
*)
41+
echo "Wrong python version (2 or 3)"
42+
exit 1;;
43+
esac
44+
2645
docker run --name gitlab-test --detach --publish 8080:80 --publish 2222:22 genezys/gitlab:latest >/dev/null 2>&1
2746

2847
LOGIN='root'
@@ -31,7 +50,7 @@ CONFIG=/tmp/python-gitlab.cfg
3150
GITLAB="gitlab --config-file $CONFIG"
3251
VENV=$(pwd)/.venv
3352

34-
virtualenv $VENV
53+
$VENV_CMD $VENV
3554
. $VENV/bin/activate
3655
pip install -rrequirements.txt
3756
pip install -e .
@@ -55,7 +74,7 @@ $OK
5574
TOKEN=$(curl -s http://localhost:8080/api/v3/session \
5675
-X POST \
5776
--data "login=$LOGIN&password=$PASSWORD" \
58-
| python -c 'import sys, json; print json.load(sys.stdin)["private_token"]')
77+
| python -c 'import sys, json; print(json.load(sys.stdin)["private_token"])')
5978

6079
cat > $CONFIG << EOF
6180
[global]

0 commit comments

Comments
 (0)
X Tutup