Skip to content

Commit 26999bf

Browse files
committed
move common code to build_test_env.sh
Note that build_test_env.sh now creates and prepares the Python virtualenv (it didn't before).
1 parent 6df844a commit 26999bf

File tree

3 files changed

+23
-45
lines changed

3 files changed

+23
-45
lines changed

tools/build_test_env.sh

+21
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,26 @@ case $PY_VER in
3333
exit 1;;
3434
esac
3535

36+
VENV=$(pwd)/.venv
37+
38+
cleanup() {
39+
rm -f /tmp/python-gitlab.cfg
40+
docker kill gitlab-test >/dev/null 2>&1
41+
docker rm gitlab-test >/dev/null 2>&1
42+
deactivate || true
43+
rm -rf $VENV
44+
}
45+
[ -z "${BUILD_TEST_ENV_AUTO_CLEANUP+set}" ] || {
46+
trap cleanup EXIT
47+
}
48+
3649
docker run --name gitlab-test --detach --publish 8080:80 \
3750
--publish 2222:22 gpocentek/test-python-gitlab:latest >/dev/null 2>&1
3851

3952
LOGIN='root'
4053
PASSWORD='5iveL!fe'
4154
CONFIG=/tmp/python-gitlab.cfg
55+
GITLAB="gitlab --config-file $CONFIG"
4256
GREEN='\033[0;32m'
4357
NC='\033[0m'
4458
OK="echo -e ${GREEN}OK${NC}"
@@ -74,3 +88,10 @@ EOF
7488

7589
echo "Config file content ($CONFIG):"
7690
cat $CONFIG
91+
92+
$VENV_CMD $VENV
93+
. $VENV/bin/activate
94+
pip install -rrequirements.txt
95+
pip install -e .
96+
97+
sleep 20

tools/functional_tests.sh

+1-26
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,10 @@
1414
# You should have received a copy of the GNU Lesser General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
cleanup() {
18-
rm -f /tmp/python-gitlab.cfg
19-
docker kill gitlab-test >/dev/null 2>&1
20-
docker rm gitlab-test >/dev/null 2>&1
21-
deactivate || true
22-
rm -rf $VENV
23-
}
24-
trap cleanup EXIT
25-
2617
setenv_script=$(dirname $0)/build_test_env.sh
27-
18+
BUILD_TEST_ENV_AUTO_CLEANUP=true
2819
. $setenv_script "$@"
2920

30-
CONFIG=/tmp/python-gitlab.cfg
31-
GITLAB="gitlab --config-file $CONFIG"
32-
GREEN='\033[0;32m'
33-
NC='\033[0m'
34-
OK="echo -e ${GREEN}OK${NC}"
35-
36-
VENV=$(pwd)/.venv
37-
38-
$VENV_CMD $VENV
39-
. $VENV/bin/activate
40-
pip install -rrequirements.txt
41-
pip install -e .
42-
43-
# NOTE(gpocentek): the first call might fail without a little delay
44-
sleep 20
45-
4621
set -e
4722

4823
echo -n "Testing project creation... "

tools/py_functional_tests.sh

+1-19
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,8 @@
1414
# You should have received a copy of the GNU Lesser General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
cleanup() {
18-
rm -f /tmp/python-gitlab.cfg
19-
docker kill gitlab-test >/dev/null 2>&1
20-
docker rm gitlab-test >/dev/null 2>&1
21-
deactivate || true
22-
rm -rf $VENV
23-
}
24-
trap cleanup EXIT
25-
2617
setenv_script=$(dirname $0)/build_test_env.sh
27-
18+
BUILD_TEST_ENV_AUTO_CLEANUP=true
2819
. $setenv_script "$@"
2920

30-
VENV=$(pwd)/.venv
31-
32-
$VENV_CMD $VENV
33-
. $VENV/bin/activate
34-
pip install -rrequirements.txt
35-
pip install -e .
36-
37-
sleep 20
38-
3921
python $(dirname $0)/python_test.py

0 commit comments

Comments
 (0)